IMail Transport ExtensionsSend Async(IMail Transport, Mime Message, Mailbox Address, IEnumerableMailbox Address, Cancellation Token, ITransfer Progress) Method
Asynchronously send the specified message using the supplied sender and recipients.
Definition
Namespace: MailKit
Assembly: MailKit (in MailKit.dll) Version: 5.0.0
The result of sending the message.
Assembly: MailKit (in MailKit.dll) Version: 5.0.0
C#
public static Task<SendResult> SendAsync(
this IMailTransport transport,
MimeMessage message,
MailboxAddress sender,
IEnumerable<MailboxAddress> recipients,
CancellationToken cancellationToken = default,
ITransferProgress? progress = null
)Parameters
- transport IMailTransport
- The transport.
- message MimeMessage
- The message.
- sender MailboxAddress
- The mailbox address to use for sending the message.
- recipients IEnumerableMailboxAddress
- The mailbox addresses that should receive the message.
- cancellationToken CancellationToken (Optional)
- The cancellation token.
- progress ITransferProgress (Optional)
- The progress reporting mechanism.
Return Value
TaskSendResultThe result of sending the message.
Usage Note
In Visual Basic and C#, you can call this method as an instance method on any object of type IMailTransport. When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).Remarks
Asynchronously sends the specified message using the supplied sender and recipients.
Exceptions
| ArgumentNullException |
message is . -or- sender is . -or- recipients is . |
| ObjectDisposedException | The IMailTransport has been disposed. |
| ServiceNotConnectedException | The IMailTransport is not connected. |
| ServiceNotAuthenticatedException | Authentication is required before sending a message. |
| InvalidOperationException |
A sender has not been specified. -or- No recipients have been specified. |
| OperationCanceledException | The operation has been canceled. |
| IOException | An I/O error occurred. |
| CommandException | The send command failed. |
| ProtocolException | A protocol exception occurred. |