Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <system.net>
- <connectionManagement>
- <add address="*" maxconnection="392" />
- </connectionManagement>
- <mailSettings>
- <smtp from="form@company.com" deliveryMethod="Network">
- <network host="email-smtp.us-east-1.amazonaws.com" userName="SmtpUsername" password="SmtpPassword" enableSsl="true" port="587" />
- </smtp>
- </mailSettings>
- </system.net>
- class Program
- {
- static readonly object syncRoot = new object();
- private readonly static int maxParallelEmails = 196;
- static void Main(string[] args)
- {
- IList<Model.SendEmailTo> recipients = _emailerService.GetEmailsToSend();
- int cnt = 0;
- int totalCnt = recipients.Count;
- Parallel.ForEach(recipients.AsParallel(), new ParallelOptions { MaxDegreeOfParallelism = maxParallelEmails }, recipient =>
- {
- // Do any other logic
- // Build the email HTML
- // Send the email, make sure to log exceptions
- // Track email, etc
- lock (syncRoot) cnt++;
- Console.WriteLine(String.Format("{0}/{1} - Sent newsletter email to: {2}", cnt, totalCnt, recipient.Email));
- });
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement