Name: |
12/19/09
11/27/09
Send Email in asp.net [vb] using gmail
Imports System.Net.MailPartial Class _Default
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim MyMailMessage As New MailMessage
MyMailMessage.To.Add("To_mail_ID")
MyMailMessage.Subject = "This is the mail subject"
MyMailMessage.Body = "Just wanted to say Hello"
Dim mFrom As MailAddress = New MailAddress("From_mail_id")
Try
MyMailMessage.From = mFrom
MyMailMessage.IsBodyHtml = False
Dim mailAuthentication As New System.Net.NetworkCredential mailAuthentication.UserName = "From_mail_id"
mailAuthentication.Password = "From_mail_id_password"
Dim sm As SmtpClient = New SmtpClient("smtp.gmail.com", 587)
sm.EnableSsl = True
sm.UseDefaultCredentials = False
sm.Credentials = mailAuthentication
sm.Send(MyMailMessage)
Catch ex As Exception
MsgBox(ex.Message)
End Try
Response.Write("Your Message has been sent successfully")
End Sub
End Class
1/15/09
Subscribe to:
Posts (Atom)