The SmtpMail class can be used to send mails from your VB application. Mail is by default queued on the system, ensuring that the calling program does not block network traffic. The SmtpMail class is defined in the namespace System.Web.Mail. You need to call
Imports System.Web.Mail
before you use SmtpMail. This class has only one member function Send. Send sends a mail message. The Send method is overloaded. Either a MailMessage class or four arguments can be passed to the Send message. You can call the Send method in two manners:
SmtpMail.Send(txtFrom.Text, txtTo.Text, txtSubject.Text, txtMessage.Text)
Or, if you don't want to call System.Web.Util.
System.Web.Mail.SmptMail.Send(fromString, toString, SubjeOfTheMailString, MessageOfTheMailString)
You can call the Send method in two ways.
1. By passing MailMessage as a parameter,
Code:
public static void Send(MailMessage).
Here MailMessage is a class.
Private mailMsg As MailMessage = New MailMessage()
Private mailMsg.From = from@fromServer.com
Private mailMsg.To = to@toServer.com
Private mailMsg.Cc = cc@ccServer.com"
Private mailMsg.Bcc = bcc@bccServer.com
Private mailMsg.Subject = "SubjectOfTheMailString"
Private mailMsg.Body = "BodyOfTheMailString"
SmtpMail.Send(mailMsg).