Send email from asp.net 2.0

Hello guys here i have presented one of the way, to send email message from web application.

As, email notification has become essential functionality now a days in most of dynamic websites.

Below code i have represent in VB.Net language.

Hope it might be usefull

🙂

Dim Email As New System.Net.Mail.MailMessage(“fromaddress@test.com”, “toaddress@test.com”)

Email.Subject = “Test mail subject goes here.”
Email.Body = “You can place desired content here.”

Dim mailClient As New System.Net.Mail.SmtpClient()

‘This object stores the authentication values
Dim basicAuthenticationInfo As New System.Net.NetworkCredential(“validemail@gmail.com”, “validpassword”)

‘Put your own, or your ISPs, mail server name on this next line
mailClient.Host = “smtp.gmail.com”
mailClient.Port = 587
mailClient.EnableSsl = True
mailClient.UseDefaultCredentials = False
mailClient.Credentials = basicAuthenticationInfo

mailClient.Send(Email)

Advertisements