Guest User

Untitled

a guest
Feb 17th, 2018
30
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 KB | None | 0 0
  1. protected void Button1_Click(object sender, EventArgs e)
  2. {
  3. try
  4. {
  5. MailMessage mail = new MailMessage();
  6. SmtpClient SmtpServer = new SmtpClient("smtp.gmail.com");
  7.  
  8. mail.From = new MailAddress("sachinsnimbalkar@gmail.com");
  9. mail.To.Add("vaibhavlokhande55@gmail.com");
  10. mail.Subject = "Test Mail from sachin nimbalkar";
  11. mail.Body = "This is for testing SMTP mail from GMAIL";
  12.  
  13. SmtpServer.Port = 587;
  14. SmtpServer.Credentials = new System.Net.NetworkCredential("sachinsnimbalkar@gmail.com", "YourPassword");
  15. SmtpServer.EnableSsl = true;
  16.  
  17. SmtpServer.Send(mail);
  18. Button1.Text ="mail Send";
  19. }
  20. catch (Exception ex)
  21. {
  22. Button1.Text=ex.ToString();
  23. }
  24. }
Add Comment
Please, Sign In to add comment