Dim Smtp As New EASendMailObjLib.Mail Smtp.LicenseCode = "TryIt" Smtp.FromAddr = eid '"ab@mail.com" Smtp.AddRecipientEx(email, 0) Smtp.Subject = "abcde" Smtp.BodyText = "abcde" '' Add attachment from local disk If Smtp.AddAttachment(pdfFile) <> 0 Then MsgBox("Failed to add attachment with error:" & Smtp.GetLastErrDescription()) End If Smtp.ServerAddr = server '"smtp.gmail.com" Smtp.ServerPort = port ' 465 '' detect SSL/TLS automatically Smtp.SSL_init() Smtp.UserName = eid '"ab@mail.com" Smtp.Password = pass '"123" If Smtp.SendMail() = 0 Then '' MsgBox("email was sent successfully!") Label1.Text = "1" Else MsgBox("failed to send email with the following error:" & Smtp.GetLastErrDescription()) End If Else End If Next If Label1.Text = "1" Then MsgBox("email was sent successfully!") End If Label1.Text = "" End If
System.Net.Mail.SmtpClient
Imports System.Net Imports System.Net.Mail ' add these lines at the top of your file
Dim Smtp As New SmtpClient(server, port) Dim msg As New MailMessage() msg.From = New MailAddress(eid) msg.[To].Add(email) msg.Subject = "abcde" msg.Body = "abcde" msg.IsBodyHtml = True ' if your email body is not HTML, change this into false or remove this line msg.Attachments.Add(New Attachment(pdfFile)) Smtp.EnableSsl = True Smtp.Credentials = New NetworkCredential(eid, pass) Try Smtp.Send(msg) Label1.Text = "1" Catch e As Exception MsgBox("failed to send email with the following error:" + e.Message) End Try ' now, add other code if you want
<small>Smtp.UserName = eid '"ab@mail.com"Smtp.Password = pass '"123"</small>
<small>eid</small>
<small>pass</small>
(
)
<small>msg.To.Add('emailAddress1@example.com');msg.To.Add('emailAddress2@example.com');</small>
<small> Dim Smtp As New EASendMailObjLib.Mail Smtp.LicenseCode = "TryIt" Smtp.FromAddr = eid '"ab@mail.com" Smtp.AddRecipientEx(email, 0) Smtp.Subject = "aabb" Smtp.BodyText = "aabb" '' Add attachment from local disk If Smtp.AddAttachment(pdfFile) <> 0 Then MsgBox("Failed to add attachment with error:" & Smtp.GetLastErrDescription()) End If Smtp.ServerAddr = server '"smtp.gmail.com" Smtp.ServerPort = port ' 465 '' detect SSL/TLS automatically Smtp.SSL_init() Smtp.UserName = eid '"ab@mail.com" Smtp.Password = pass '"123" If Smtp.SendMail() = 0 Then '' MsgBox("email was sent successfully!") Label1.Text = "1" Else MsgBox("failed to send email with the following error:" & Smtp.GetLastErrDescription()) End If Else End If Next If Label1.Text = "1" Then MsgBox("email was sent successfully!") End If</small>
<small>Dim Smtp As New SmtpClient(server, port)Dim msg As New MailMessage()msg.From = New MailAddress(eid)msg.[To].Add(email)msg.Subject = "abcde"msg.Body = "abcde"msg.IsBodyHtml = True' if your email body is not HTML, change this into false or remove this linemsg.Attachments.Add(New Attachment(pdfFile))Smtp.EnableSsl = TrueSmtp.Credentials = New NetworkCredential(eid, pass)Try Smtp.Send(msg) Label1.Text = "1"Catch e As Exception MsgBox("failed to send email with the following error:" + e.Message)End Try</small>
<small>Imports System.Net.MailImports System.Net</small>
<small>System.IO.File.Delete(pathOfYourPdfFile)</small>
<small>msg.Dispose()System.IO.File.Delete(pathOfYourPdfFile)</small>
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)