|
Sending an Email message |
|
To send an email message first establish a connection to the SMTP server and then invoke the Send method on an Smtp instance passing an EmailMessage instance as an argument.
Example
This example creates an email message with the To and From email address, sets the message subject and body properties, then sends the message.
[C#]
Smtp smtp = new Smtp("smtp.myserver.com");
smtp.Connect();
// build message
EmailMessage message = new EmailMessage("jsmith@myserver.com", "mjones@yourserver.com");
message.Subject = "Meeting today at 2:30 p.m.";
message.SetBody("See you then.");
// send message
smtp.Send(message);
// release connection
smtp.Disconnect();
[Visual Basic]
Dim mySmtp As Smtp = Nothing
Dim message As EmailMessage = Nothing
mySmtp = New Smtp("smtp.myserver.com")
mySmtp.Connect()
' build message
message = New EmailMessage("jsmith@myserver.com", "mjones@yourserver.com")
message.Subject = "Meeting today at 2:30 p.m."
message.SetBody("See you then.")
' send message
mySmtp.Send(message)
' release connection
mySmtp.Disconnect()