System.Web.Mail.SmtpMail.Send Method

Sends an e-mail message using arguments supplied in the properties of the System.Web.Mail.MailMessage class. Recommended alternative: System.Net.Mail.

Syntax

public static void Send (MailMessage message)

Parameters

message
The System.Web.Mail.MailMessage to send.

Remarks

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);
    }
}
              

Requirements

Namespace: System.Web.Mail
Assembly: System.Web (in System.Web.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0