Advertisement
Guest User

Untitled

a guest
Aug 26th, 2015
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. Imports System.Net.Mail
  2. Public Class Form1
  3. Private Sub Button1_Click(ByVal sender As System.Object,
  4. ByVal e As System.EventArgs) Handles Button1.Click
  5. Try
  6. Dim SmtpServer As New SmtpClient()
  7. Dim mail As New MailMessage()
  8. SmtpServer.Credentials = New _
  9. Net.NetworkCredential("username@gmail.com", "password")
  10. SmtpServer.Port = 587
  11. SmtpServer.Host = "smtp.gmail.com"
  12. mail = New MailMessage()
  13. mail.From = New MailAddress("YOURusername@gmail.com")
  14. mail.To.Add("TOADDRESS")
  15. mail.Subject = "Test Mail"
  16. mail.Body = "This is for testing SMTP mail from GMAIL"
  17. SmtpServer.Send(mail)
  18. MsgBox("mail send")
  19. Catch ex As Exception
  20. MsgBox(ex.ToString)
  21. End Try
  22. End Sub
  23. End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement