· 9 years ago · Jul 21, 2017, 07:46 AM
1Dim SmtpServer As New SmtpClient()
2SmtpServer.Credentials = New Net.NetworkCredential("mymailid@gmail.com", "mypassword")
3SmtpServer.Port = 25
4SmtpServer.Host = "smtp.gmail.com"
5SmtpServer.EnableSsl = True
6mail = New MailMessage()
7Dim addr() As String = TextBox1.Text.Split(",")
8Try
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
23Dim SmtpServer As New SmtpClient("smtp.gmail.com", 587)
24Dim mail As New MailMessage("sender address", "destination address", "subject", "body")
25SmtpServer.Credentials = New Net.NetworkCredential("username/sender address","password")
26SmtpServer.Send(Mail)
27
28Dim 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
47Dim 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
53Imports System.Net.Mail
54Public 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