Change language to English
  Buscar un Dominio
 
  Detalles Ayuda General.
How to send email using ASP.NET2 VB

'This is an example only, and needs to be modified with proper information


Sub SendEmail()

'create the mail message
Dim nmail As New System.Net.Mail.MailMessage

'set the addresses
nmail.To.Clear()
nmail.To.Add(New System.Net.Mail.MailAddress("recipient name "))
nmail.From = New System.Net.Mail.MailAddress("my name ")

'set the content
nmail.Subject = "This is an email"
nmail.Body = "this is the body content of the email."

'prepare to send the message
Dim smtp As System.Net.Mail.SmtpClient = New System.Net.Mail.SmtpClient("mail.mydomain.tld")

'you need to use the credentials of an existing mail account
smtp.Credentials = New System.Net.NetworkCredential("me@mydomain.tld", "mypassword")

Try
smtp.Send(nmail)
Catch ex As Exception
Response.Write("Error: " & ex.ToString())
End Try

End Sub