Click or drag to resize
MimeKit

MailTransportSendAsync(MimeMessage, MailboxAddress, IEnumerableMailboxAddress, CancellationToken, ITransferProgress) Method

Asynchronously send the specified message using the supplied sender and recipients.

Namespace: MailKit
Assembly: MailKit (in MailKit.dll) Version: 4.7.1
Syntax
C#
public virtual Task<string> SendAsync(
	MimeMessage message,
	MailboxAddress sender,
	IEnumerable<MailboxAddress> recipients,
	CancellationToken cancellationToken = default,
	ITransferProgress progress = null
)

Parameters

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

TaskString
The final free-form text response from the server.

Implements

IMailTransportSendAsync(MimeMessage, MailboxAddress, IEnumerableMailboxAddress, CancellationToken, ITransferProgress)
Exceptions
ExceptionCondition
ArgumentNullException

message is null.

-or-

sender is null.

-or-

recipients is null.

ObjectDisposedException The MailTransport has been disposed.
ServiceNotConnectedException The MailTransport 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.
Remarks
Asynchronously sends the specified message using the supplied sender and recipients.
See Also