Login to an SMTP server and send an email
There are many articles on how to send authenticated email in ASP.NET 2.0, but here's how to send an email using a SMTP server that requires authentication.
(Imports System.Net)
Dim client As New SmtpClient("smtp.server.com")
client.UseDefaultCredentials = False
client.Credentials = New Net.NetworkCredential("username", "password")
client.DeliveryMethod = SmtpDeliveryMethod.Network
Dim Mail As New MailMessage("from@email.com", "to@email.com", _
"This is my subject", _
"This is my pretty, yet boring and useless message")
Mail.IsBodyHtml = True
Try
client.Send(Mail)
Catch ex As Exception
Response.Write(ex.Message)
Exit Sub
End Try
I am a software programmer from Bucharest, Romania.
I am 24 years old and I am very pleased with my job at
Elven Soft, a company specialized in custom software development and web design