Advertisement
Guest User

Untitled

a guest
Jul 21st, 2017
498
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.88 KB | None | 0 0
  1. Dim SmtpServer As New SmtpClient()
  2. SmtpServer.Credentials = New Net.NetworkCredential("mymailid@gmail.com", "mypassword")
  3. SmtpServer.Port = 25
  4. SmtpServer.Host = "smtp.gmail.com"
  5. SmtpServer.EnableSsl = True
  6. mail = New MailMessage()
  7. Dim addr() As String = TextBox1.Text.Split(",")
  8. Try
  9. mail.From = New MailAddress("mymailid@gmail.com", "Developers", System.Text.Encoding.UTF8)
  10. Dim i As Byte
  11. For i = 0 To addr.Length - 1
  12. mail.To.Add(addr(i))
  13. Next
  14. mail.Subject = TextBox3.Text
  15. 'mail.Body = TextBox4.Text
  16. If ListBox1.Items.Count <> 0 Then
  17. For i = 0 To ListBox1.Items.Count - 1
  18. mail.Attachments.Add(New Attachment(ListBox1.Items.Item(i)))
  19. Next
  20. End If
  21. SmtpServer.SendAsync(mail, mail.Subject)
  22.  
  23. Dim SmtpServer As New SmtpClient("smtp.gmail.com", 587)
  24. Dim mail As New MailMessage("sender address", "destination address", "subject", "body")
  25. SmtpServer.Credentials = New Net.NetworkCredential("username/sender address","password")
  26. SmtpServer.Send(Mail)
  27.  
  28. Dim SmtpServer As New SmtpClient()
  29. SmtpServer.Credentials = New Net.NetworkCredential("EMAIL FROM@gmail.com", "YOUR PASSWORD")
  30. SmtpServer.Port = 25
  31. SmtpServer.Host = "smtp.gmail.com"
  32. SmtpServer.EnableSsl = True
  33. Dim omail As New MailMessage()
  34.  
  35.  
  36. omail.From = New MailAddress("FROM EMAIL @gmail.com", "Asfand Iqbal", System.Text.Encoding.UTF8)
  37.  
  38. omail.Subject = "test subject"
  39. omail.To.Add("test@gmail.com")
  40.  
  41. SmtpServer.SendAsync(omail, Nothing)
  42.  
  43. Catch ex As Exception
  44. MsgBox(ex.ToString)
  45. End Try
  46.  
  47. Dim SmtpServer As New SmtpClient("smtp.gmail.com", 465)
  48. SmtpServer.EnableSsl = True
  49. SmtpServer.Credentials = New Net.NetworkCredential("name@gmail.com", "password")
  50. Dim mail As New MailMessage("name@gmail.com", "name@gmail.com", title, content)
  51. SmtpServer.Send(mail)
  52.  
  53. Imports System.Net.Mail
  54. Public Class Form1
  55. Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
  56. ' Set the caption bar text of the form.
  57. Me.Text = "tutorialspoint.com"
  58. End Sub
  59.  
  60. Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
  61. Try
  62. Dim Smtp_Server As New SmtpClient
  63. Dim e_mail As New MailMessage()
  64. Smtp_Server.UseDefaultCredentials = False
  65. Smtp_Server.Credentials = New Net.NetworkCredential("username@gmail.com", "password")
  66. Smtp_Server.Port = 587
  67. Smtp_Server.EnableSsl = True
  68. Smtp_Server.Host = "smtp.gmail.com"
  69.  
  70. e_mail = New MailMessage()
  71. e_mail.From = New MailAddress(txtFrom.Text)
  72. e_mail.To.Add(txtTo.Text)
  73. e_mail.Subject = "Email Sending"
  74. e_mail.IsBodyHtml = False
  75. e_mail.Body = txtMessage.Text
  76. Smtp_Server.Send(e_mail)
  77. MsgBox("Mail Sent")
  78.  
  79. Catch error_t As Exception
  80. MsgBox(error_t.ToString)
  81. End Try
  82.  
  83. End Sub
  84. 'Ghaffari
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement