Advertisement
Guest User

Untitled

a guest
Feb 22nd, 2016
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. bool flag = false;
  2. var message = new MailMessage();
  3. try
  4. {
  5. message.To.Clear();
  6. message.To.Add(new MailAddress(to));
  7.  
  8. message.From = new MailAddress(from);
  9.  
  10. message.Subject = subject;
  11.  
  12. message.Body = body;
  13.  
  14. message.IsBodyHtml = true;
  15.  
  16. using (var smtp = new SmtpClient())
  17. {
  18.  
  19.  
  20. var credential = new NetworkCredential
  21. {
  22. UserName = "Email@mail.com",
  23. Password = "password"
  24. };
  25. smtp.Credentials = credential;
  26. smtp.Host = "smtp-mail.outlook.com";
  27. smtp.Port = 587;
  28.  
  29. smtp.EnableSsl = true;
  30. smtp.Send(message);
  31.  
  32.  
  33. }
  34. flag = true;
  35. }
  36. catch (Exception ex)
  37. {
  38.  
  39. }
  40.  
  41. return flag;
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement