To include automated mail sending in your code, simply import System.Net and System.Net.Mail in your code:
Imports System.Net
Imports System.Net.Mail
...
and on your calling function simply make a call to SmtpClient.Send()
Dim yourMail As SmtpClient = New SmtpClient("your.email.server")
SmtpClient.Send() have two overloaded function calls
1. SmtpClient.Send(message as System.Net.MailMessage)
2. SmtpClient.Send(from as String, recipients as String, subject as String, Body as String)
To customize your message you may use System.Net.Mail.MailMessage(). Example:
...
Dim theMessage As MailMessage = New MailMessage
theMessage.From = New MailAddress("[email protected]")
theMessage.To.Add("[email protected]")
theMessage.Subject = "The Subject"
theMessage.Body = "The body bla bla bla."
To send message as html just assign MailMessage.isBodyHtml to true:
...
theMessage.IsBodyHtml = True
theMessage.Body = "<HTML><HEAD>Subject</HEAD>" + _
"<BODY>your body bla bla bla</BODY></HTML>"
Dim theMail As SmtpClient = New SmtpClient("yourmailserver.local.domain")
theMail.Credentials = New NetworkCredential("username", "password")
theMail.Send(theMessage)
Imports System.Net
Imports System.Net.Mail
...
and on your calling function simply make a call to SmtpClient.Send()
Dim yourMail As SmtpClient = New SmtpClient("your.email.server")
SmtpClient.Send() have two overloaded function calls
1. SmtpClient.Send(message as System.Net.MailMessage)
2. SmtpClient.Send(from as String, recipients as String, subject as String, Body as String)
To customize your message you may use System.Net.Mail.MailMessage(). Example:
...
Dim theMessage As MailMessage = New MailMessage
theMessage.From = New MailAddress("[email protected]")
theMessage.To.Add("[email protected]")
theMessage.Subject = "The Subject"
theMessage.Body = "The body bla bla bla."
To send message as html just assign MailMessage.isBodyHtml to true:
...
theMessage.IsBodyHtml = True
theMessage.Body = "<HTML><HEAD>Subject</HEAD>" + _
"<BODY>your body bla bla bla</BODY></HTML>"
Dim theMail As SmtpClient = New SmtpClient("yourmailserver.local.domain")
theMail.Credentials = New NetworkCredential("username", "password")
theMail.Send(theMessage)