SmtpClient.SendMailAsync Method

Definition

Sends the specified message to an SMTP server for delivery as an asynchronous operation.

Overloads

SendMailAsync(MailMessage)

Sends the specified message to an SMTP server for delivery as an asynchronous operation.

SendMailAsync(String, String, String, String)

Sends the specified message to an SMTP server for delivery as an asynchronous operation. . The message sender, recipients, subject, and message body are specified using String objects.

SendMailAsync(MailMessage)

Sends the specified message to an SMTP server for delivery as an asynchronous operation.

public:
 System::Threading::Tasks::Task ^ SendMailAsync(System::Net::Mail::MailMessage ^ message);
public System.Threading.Tasks.Task SendMailAsync (System.Net.Mail.MailMessage message);
member this.SendMailAsync : System.Net.Mail.MailMessage -> System.Threading.Tasks.Task
Public Function SendMailAsync (message As MailMessage) As Task

Parameters

message
MailMessage

A MailMessage that contains the message to send.

Returns

The task object representing the asynchronous operation.

Exceptions

message is null.

Remarks

This operation will not block. The returned Task object will complete once the message has been sent.

SendMailAsync(String, String, String, String)

Sends the specified message to an SMTP server for delivery as an asynchronous operation. . The message sender, recipients, subject, and message body are specified using String objects.

public:
 System::Threading::Tasks::Task ^ SendMailAsync(System::String ^ from, System::String ^ recipients, System::String ^ subject, System::String ^ body);
public System.Threading.Tasks.Task SendMailAsync (string from, string recipients, string subject, string body);
member this.SendMailAsync : string * string * string * string -> System.Threading.Tasks.Task
Public Function SendMailAsync (from As String, recipients As String, subject As String, body As String) As Task

Parameters

from
String

A String that contains the address information of the message sender.

recipients
String

A String that contains the addresses that the message is sent to.

subject
String

A String that contains the subject line for the message.

body
String

A String that contains the message body.

Returns

The task object representing the asynchronous operation.

Exceptions

from is null.

-or-

recipients is null.

from is Empty.

-or-

recipients is Empty.

Remarks

This operation will not block. The returned Task object will complete once the message has been sent.

Applies to