Smtp ClientSend Async(Format Options, ISend Request, Cancellation Token) Method
Definition
Assembly: MailKit (in MailKit.dll) Version: 5.0.0
public override Task<SendResult> SendAsync(
FormatOptions options,
ISendRequest request,
CancellationToken cancellationToken = default
)Parameters
- options FormatOptions
- The formatting options.
- request ISendRequest
- The send request.
- cancellationToken CancellationToken (Optional)
- The cancellation token.
Return Value
TaskSendResultThe result of sending the message as an SmtpSendResult.
Implements
IMailTransportSendAsync(FormatOptions, ISendRequest, CancellationToken)IMailTransportSendAsync(FormatOptions, ISendRequest, CancellationToken)
Remarks
Asynchronously sends the message specified by the request.
If the Sender is , the sender address is determined by checking the following message headers (in order of precedence): Resent-Sender, Resent-From, Sender, and From.
If the Recipients is , the recipients are collected from the Resent-To, Resent-Cc, and Resent-Bcc headers if either the Resent-Sender or Resent-From addresses are present, otherwise the To, Cc, and Bcc headers are used.
If the request implements ISmtpSendRequest, it may also be used to request delivery status notifications and to handle the server's response to each MAIL FROM and RCPT TO command.
Exceptions
| ArgumentNullException |
options is . -or- request is . |
| ObjectDisposedException | The SmtpClient has been disposed. |
| ServiceNotConnectedException | The SmtpClient is not connected. |
| ServiceNotAuthenticatedException | Authentication is required before sending a message. |
| InvalidOperationException |
A sender has not been specified. -or- No recipients have been specified. |
| NotSupportedException | Internationalized formatting was requested but is not supported by the server. |
| SmtpUtf8AddressException | The message is being sent using the SMTPUTF8 extension and the sender or one of the recipients is not a valid SMTPUTF8 address. |
| OperationCanceledException | The operation has been canceled. |
| IOException | An I/O error occurred. |
| SmtpCommandException | The SMTP command failed. |
| SmtpProtocolException | An SMTP protocol exception occurred. |