Advertisement
Guest User

Untitled

a guest
May 24th, 2016
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.99 KB | None | 0 0
  1. public static SmtpClient mySmtpClient = new SmtpClient("smtp.gmail.com", 587);
  2. public static void SendEmail(Email myMail)
  3. {
  4. mySmtpClient.EnableSsl = true;
  5. //mySmtpClient.UseDefaultCredentials = true;
  6.  
  7. mySmtpClient.Credentials = new NetworkCredential()
  8. {
  9. UserName = "sunaulosamajnepal@gmail.com",
  10. Password = "2016sunaulonepal",
  11. };
  12.  
  13. //create sender address
  14. MailAddress to = new MailAddress("sunaulosamajnepal@gmail.com", "Sunaulo Pragatisil Samaj Nepal (Golden progressive Society Nepal");
  15.  
  16. //create receiver address
  17. MailAddress receiver = new MailAddress(myMail.To.Trim(), myMail.Name.Trim());
  18.  
  19. // create sender addresss
  20. MailAddress from = new MailAddress(myMail.From.Trim());
  21.  
  22. MailMessage Mymessage = new MailMessage(to, receiver, from);
  23. Mymessage.Subject = myMail.Subject.Trim();
  24. Mymessage.Body = myMail.Body.Trim();
  25.  
  26.  
  27. mySmtpClient.Send(Mymessage);
  28.  
  29. }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement