System.Web.Mail.SmtpMail.Send Method

Sends an e-mail message using the specified destination parameters. Recommended alternative: System.Net.Mail.

Syntax

public static void Send (string from, string to, string subject, string messageText)

Parameters

from
The address of the e-mail sender.
to
The address of the e-mail recipient.
subject
The subject line of the e-mail message.
messageText
The body of the e-mail message.

Remarks

This is a method that sends an e-mail message over the SMTP protocol. It connects to the SMTP server as specified in SmtpMail.SmtpServer and sends the e-mail to to. This method is a simplified version of SmtpMail.Send(MailMessage) which is actually used by this method for sending e-mails.

Here is a simple example to show how to send an e-mail.

C# Example

using System;
using System.Web.Mail;

public class SmtpTest {
    
    public static void Main (String[] args) 
    {
	SmtpMail.SmtpServer = "mail.foo.bar";
	SmtpMail.Send ("per@foo.bar","ola@foo.bar","Hello, E-Mail world!","This is a test mail.");
    }
}
              

Requirements

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