Sends an e-mail message using arguments supplied in the properties of the System.Web.Mail.MailMessage class. Recommended alternative: System.Net.Mail.
- message
The System.Web.Mail.MailMessage to send.
This method sends an e-mail to the recipients specified in the System.Web.Mail.MailMessage parameter message. The e-mail is sent over the SMTP protocol through the server specified in SmtpMail.SmtpServer.
This example shows the typical usage of the SmtpMail.Send method. To run this sample you have to change the e-mail addresses and the SMTP server to real ones.
C# Example
using System; using System.Web.Mail; public class SmtpTest { public static void Main (String[] args) { MailMessage message = new MailMessage(); message.From = "per@foo.bar"; message.To = "ola@foo.bar"; message.Subject = "Hello, E-Mail world!"; message.Body = "This is a test mail."; SmtpMail.SmtpServer = "mail.foo.bar"; SmtpMail.Send (message); } }