Sending an HTML 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 HtmlEmailMessage instance as an argument.
Example
[C#] Smtp smtp = new Smtp("smtp.myserver.com"); smtp.Connect();
// build message HtmlEmailMessage message = new HtmlEmailMessage();
message.To = "jsmith@myserver.com"; message.From = "rjones@myserver.com"; message.Subject = "Meeting at 8";
message.SetTextBody("this is the text body"); message.SetHtmlBody("<html><body><img src=\"cid:12345\"><br>this is the html body</body></html>");
message.Embed("http://www.domain.com/image.gif","12345");
// send message smtp.Send(message);
// release connection smtp.Disconnect();
[Visual Basic] Dim smtp As Smtp = New Smtp("smtp.myserver.com") smtp.Connect()
' build message Dim message As HtmlEmailMessage = New HtmlEmailMessage
message.To = "jsmith@myserver.com" message.From = "rjones@myserver.com" message.Subject = "Meeting at 8"
message.SetTextBody("this is the text body") message.SetHtmlBody("<html><body><img src='cid:12345'><br>this is the html body</body></html>")
message.Embed("http://www.domain.com/image.gif", "12345")
' send message smtp.Send(message)
' release connection smtp.Disconnect() |