Guest User

Untitled

a guest
Oct 5th, 2018
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. MailMessage mail = new MailMessage();
  2. mail.From = new MailAddress("from@gmail.com", "fromName");
  3. mail.To.Add(new MailAddress("to@gmail.com", "toName");
  4.  
  5. mail.Subject = "Example Mail Subject";
  6.  
  7. mail.Body = "Hello,\n\n" + "Example Body Texting\n\n" + "Have a nice day!";
  8.  
  9. SmtpClient smtp = new SmtpClient();
  10. smtp.Host = "mail.server.com";
  11. smtp.Port = 587;
  12.  
  13. smtp.UseDefaultCredentials = false;
  14. var credential = new NetworkCredential
  15. {
  16. UserName = "mail user name",
  17. Password = "mail user password"
  18. };
  19. smtp.Credentials = credential;
  20. smtp.EnableSsl = false;
  21. smtp.Send(mail);
Add Comment
Please, Sign In to add comment