SmtpClient.SendMailAsync 方法

定义

将指定的邮件以异步操作形式发送给 SMTP 服务器供传递。Sends the specified message to an SMTP server for delivery as an asynchronous operation.

重载

SendMailAsync(MailMessage)

将指定的邮件以异步操作形式发送给 SMTP 服务器供传递。Sends the specified message to an SMTP server for delivery as an asynchronous operation.

SendMailAsync(String, String, String, String)

将指定的邮件以异步操作形式发送给 SMTP 服务器供传递。Sends the specified message to an SMTP server for delivery as an asynchronous operation. . 使用 String 对象指定邮件的发件人、收件人、主题和邮件正文。The message sender, recipients, subject, and message body are specified using String objects.

SendMailAsync(MailMessage)

将指定的邮件以异步操作形式发送给 SMTP 服务器供传递。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

参数

message
MailMessage

一个包含要发送的邮件的 MailMessageA MailMessage that contains the message to send.

返回

表示异步操作的任务对象。The task object representing the asynchronous operation.

异常

messagenullmessage is null.

注解

此操作不会阻止。This operation will not block. 发送消息后,将完成返回的 Task 对象。The returned Task object will complete once the message has been sent.

SendMailAsync(String, String, String, String)

将指定的邮件以异步操作形式发送给 SMTP 服务器供传递。Sends the specified message to an SMTP server for delivery as an asynchronous operation. . 使用 String 对象指定邮件的发件人、收件人、主题和邮件正文。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

参数

from
String

一个包含邮件发件人的地址信息的 StringA String that contains the address information of the message sender.

recipients
String

一个包含邮件收件人的地址的 StringA String that contains the addresses that the message is sent to.

subject
String

一个包含邮件主题行的 StringA String that contains the subject line for the message.

body
String

一个包含邮件正文的 StringA String that contains the message body.

返回

表示异步操作的任务对象。The task object representing the asynchronous operation.

异常

fromnullfrom is null.

-或--or- recipientsnullrecipients is null.

fromEmptyfrom is Empty.

-或--or- recipientsEmptyrecipients is Empty.

注解

此操作不会阻止。This operation will not block. 发送消息后,将完成返回的 Task 对象。The returned Task object will complete once the message has been sent.

适用于