Guest User

Untitled

a guest
Mar 16th, 2018
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.79 KB | None | 0 0
  1. var emailMessage = new MailMessage();
  2. emailMessage.To.Add(new MailAddress(emailRecipicant,customerName.Trim()));
  3. emailMessage.From = new MailAddress(smtpEmail);
  4. emailMessage.Subject = $"{emailSubject}";
  5. emailMessage.Body = string.Format(body);
  6. emailMessage.IsBodyHtml = true;
  7.  
  8.  
  9.  
  10. using (var smtp = new SmtpClient())
  11. {
  12. smtp.UseDefaultCredentials = false;
  13. var credential = new NetworkCredential
  14. {
  15. UserName = smtpUsername,
  16. Password = smtpPassword
  17. };
  18. smtp.Credentials = credential;
  19. smtp.Host = smtpHost;
  20. smtp.Port = Convert.ToInt32(smtpPort);
  21. smtp.DeliveryMethod = SmtpDeliveryMethod.Network;
  22. //smtp.DeliveryMethod = SmtpDeliveryMethod.SpecifiedPickupDirectory;
  23. //smtp.PickupDirectoryLocation = "C:\Users\pht_000\Desktop\Customers\Email\PickUp\";
  24. smtp.EnableSsl = false;
  25. smtp.Send(emailMessage);
  26. }
  27.  
  28. foreach (var recipicant in model.ToList())
  29. {
  30. string emailRecipicant = recipicant.Email;
  31. string emailSubject = recipicant.Subject;
  32. string message1 = recipicant.Message;
  33. string encryptedLink = recipicant.EncryptedEmail;
  34. string customerName = recipicant.Contact;
  35. SendEmail(emailRecipicant, emailSubject, message1, encryptedLink, customerName);
  36.  
  37. counter++;
  38. }
Add Comment
Please, Sign In to add comment