Imports System.Net.Mail
Dim from As String = ""
'Replace this with your own correct Gmail Address
Dim to1 As String = ""
'Replace this with the Email Address to whom you want to send the mail
Dim mail As New System.Net.Mail.MailMessage
mail.To.Add(to1)
mail.From = New MailAddress(from, "CAM", System.Text.Encoding.UTF8)
mail.Subject = "This is a test mail"
mail.SubjectEncoding = System.Text.Encoding.UTF8
mail.Body = "This is Email Body Text"
mail.BodyEncoding = System.Text.Encoding.UTF8
mail.IsBodyHtml = True
mail.Priority = MailPriority.High
Dim client As SmtpClient = New SmtpClient()
'Add the Creddentials- use your own email id and password
client.Credentials = New System.Net.NetworkCredential(from, "")
' Enter password in string
client.Port = 587 ' Gmail works on this port
client.Host = "smtp.gmail.com"
client.EnableSsl = True ' Gmail works on Server Secured Layer
Try
client.Send(mail)
HttpContext.Current.Response.Write("Succeed")
Catch ex As Exception
HttpContext.Current.Response.Write(ex.Message)
End Try
Dim from As String = ""
'Replace this with your own correct Gmail Address
Dim to1 As String = ""
'Replace this with the Email Address to whom you want to send the mail
Dim mail As New System.Net.Mail.MailMessage
mail.To.Add(to1)
mail.From = New MailAddress(from, "CAM", System.Text.Encoding.UTF8)
mail.Subject = "This is a test mail"
mail.SubjectEncoding = System.Text.Encoding.UTF8
mail.Body = "This is Email Body Text"
mail.BodyEncoding = System.Text.Encoding.UTF8
mail.IsBodyHtml = True
mail.Priority = MailPriority.High
Dim client As SmtpClient = New SmtpClient()
'Add the Creddentials- use your own email id and password
client.Credentials = New System.Net.NetworkCredential(from, "")
' Enter password in string
client.Port = 587 ' Gmail works on this port
client.Host = "smtp.gmail.com"
client.EnableSsl = True ' Gmail works on Server Secured Layer
Try
client.Send(mail)
HttpContext.Current.Response.Write("Succeed")
Catch ex As Exception
HttpContext.Current.Response.Write(ex.Message)
End Try
grt work ...:)
ReplyDelete