SmtpMail.Send Method (MailMessage)

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

Namespace: System.Web.Mail
Assembly: System.Web (in system.web.dll)

public:
static void Send (
	MailMessage^ message
)
public static void Send (
	MailMessage message
)
public static function Send (
	message : MailMessage
)
Not applicable.

Parameters

message

The MailMessage to send.

Exception typeCondition

COMException

The mail cannot be sent.

PlatformNotSupportedException

The Send method requires the Microsoft Windows NT, Windows 2000, or Windows XP operating system.

The following example shows how to use MailMessage to send an e-mail message using SmtpMail.

No code example is currently available or this language may not be supported.
MailMessage myMail = new MailMessage();
myMail.set_From("from@microsoft.com");
myMail.set_To("to@microsoft.com");
myMail.set_Subject("UtilMailMessage001");
myMail.set_Priority(MailPriority.Low);
myMail.set_BodyFormat(MailFormat.Html);
myMail.set_Body("<html><body>UtilMailMessage001 - success</body></html>");
MailAttachment myAttachment = new MailAttachment("c:\\attach\\attach1."
    + "txt",MailEncoding.Base64);
myMail.get_Attachments().Add(myAttachment);
SmtpMail.set_SmtpServer("MyMailServer");
SmtpMail.Send(myMail);

Windows 98, Windows Server 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0, 1.1, 1.0

Community Additions

ADD
Show: