Advertisement
cheahengsoon

Untitled

May 16th, 2018
349
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.96 KB | None | 0 0
  1. MailMessage mail = new MailMessage();
  2. SmtpClient SmtpServer = new SmtpClient("smtp.office365.com");
  3. mail.From = new MailAddress("admin@avantustraining.com");
  4. mail.Sender = new MailAddress("admin@avantustraining.com");
  5. mail.To.Add(To);
  6. mail.Subject = "Test Mail";
  7. mail.Body = "This is for testing SMTP mail from GMAIL";
  8.  
  9.  
  10. SmtpServer.Port = 587;
  11. SmtpServer.UseDefaultCredentials = false;
  12. SmtpServer.DeliveryMethod = SmtpDeliveryMethod.Network;
  13. SmtpServer.Credentials = new System.Net.NetworkCredential("engsooncheah@avantustraining.com", "Y#98chea");
  14. //SmtpServer.UseDefaultCredentials = false;
  15. SmtpServer.EnableSsl = true;
  16.  
  17. SmtpServer.Send(mail);
  18.  
  19. Label1.Text = "Mail Send";
  20. }
  21. catch(Exception ex)
  22. {
  23. Label1.Text=ex.ToString();
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement