Advertisement
Guest User

Untitled

a guest
Sep 9th, 2016
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.05 KB | None | 0 0
  1. var message = new MailMessage();
  2. foreach (string e in userEmails)
  3. {
  4. message.To.Add(new MailAddress(e));
  5. }
  6. message.From = new MailAddress("*******@gmail.com", "Site Name");
  7. message.Subject = string.Format("{0} vs {1}", teamZero.Name, teamOne.Name);
  8. message.Body = body;
  9. message.IsBodyHtml = true;
  10.  
  11. using (var smtp = new SmtpClient())
  12. {
  13. var credential = new NetworkCredential
  14. {
  15. UserName = "**********",
  16. Password = "**********"
  17. };
  18. smtp.Credentials = credential;
  19. smtp.Host = "smtp.gmail.com";
  20. smtp.Port = 25;
  21. smtp.EnableSsl = true;
  22. try
  23. {
  24. await smtp.SendMailAsync(message);
  25. return "";
  26. }
  27. catch (Exception e)
  28. {
  29. return e.InnerException.Message;
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement