Send Email Using Gmail in ASP.NET


/ Published in: ASP
Save to your folder(s)



Copy this code and paste it in your HTML
  1. Imports System.Net.Mail
  2.  
  3. Protected Sub Button1_Click
  4. (ByVal sender As Object, ByVal e As EventArgs)
  5. Dim mail As MailMessage = New MailMessage()
  6. mail.To.Add("[email protected]")
  7. mail.To.Add("[email protected]")
  8. mail.From = New MailAddress("[email protected]")
  9. mail.Subject = "Email using Gmail"
  10.  
  11. String Body = "Hi, this mail is to test sending mail"+
  12. "using Gmail in ASP.NET"
  13. mail.Body = Body
  14.  
  15. mail.IsBodyHtml = True
  16. Dim smtp As SmtpClient = New SmtpClient()
  17. smtp.Host = "smtp.gmail.com" //Or Your SMTP Server Address
  18. smtp.Credentials = New System.Net.NetworkCredential
  19. ("[email protected]","YourGmailPassword")
  20. smtp.EnableSsl = True
  21. smtp.Send(mail)
  22. End Sub

URL: http://csharpdotnetfreak.blogspot.com/2009/08/send-email-using-gmail-in-aspnet.html

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.