Advertisement
AndrewAubury

Untitled

Aug 6th, 2015
209
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.53 KB | None | 0 0
  1. Imports EASendMail 'Add EASendMail namespace
  2.  
  3. Module Module1
  4. Sub Main()
  5. Dim oMail As New SmtpMail("TryIt")
  6. Dim oSmtp As New SmtpClient()
  7.  
  8. ' Your gmail email address
  9. oMail.From = "gmailid@gmail.com"
  10.  
  11. ' Set recipient email address, please change it to yours
  12. oMail.To = "support@emailarchitect.net"
  13.  
  14. ' Set email subject
  15. oMail.Subject = "test email from gmail account"
  16.  
  17. ' Set email body
  18. oMail.TextBody = "this is a test email sent from VB.NET project with gmail"
  19.  
  20. 'Gmail SMTP server address
  21. Dim oServer As New SmtpServer("smtp.gmail.com")
  22.  
  23. ' set 25 port, if you want to use 587 port, please change 25 to 587
  24. oServer.Port = 25
  25.  
  26. ' detect SSL/TLS automatically
  27. oServer.ConnectType = SmtpConnectType.ConnectSSLAuto
  28.  
  29. ' Gmail user authentication should use your
  30. ' Gmail email address as the user name.
  31. ' For example: your email is "gmailid@gmail.com", then the user should be "gmailid@gmail.com"
  32. oServer.User = "gmailid"
  33. oServer.Password = "yourpassword"
  34.  
  35. Try
  36.  
  37. Console.WriteLine("start to send email over SSL ...")
  38. oSmtp.SendMail(oServer, oMail)
  39. Console.WriteLine("email was sent successfully!")
  40.  
  41. Catch ep As Exception
  42.  
  43. Console.WriteLine("failed to send email with the following error:")
  44. Console.WriteLine(ep.Message)
  45. End Try
  46.  
  47. End Sub
  48. End Module
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement