Table of Contents

Method AppendAsync

Namespace
MailFathom.Application.Mail.Delivery.Filing
Assembly
MailFathom.Application.dll

AppendAsync(MailAccountId, OutgoingMailFiling, MailboxCopySource, Func<MailFolderResolution, CancellationToken, Task>, Func<AppendedMailCopy, Task>, CancellationToken)

Appends one copy, having made the caller's record of it durable first.

[SuppressMessage("Design", "CA1031:Do not catch general exception types", Justification = "Past the issued write the append may already have reached the folder, so every way it can end has to be recorded as an outcome nobody can settle rather than raised into a retry that would file a second copy.")]
public Task<MailboxCopyAppendResult> AppendAsync(MailAccountId account, OutgoingMailFiling filing, MailboxCopySource source, Func<MailFolderResolution, CancellationToken, Task> recordIssuedAsync, Func<AppendedMailCopy, Task> recordConfirmedAsync, CancellationToken cancellationToken)

Parameters

account MailAccountId

The account whose folder the copy goes into.

filing OutgoingMailFiling

Which place the copy goes into, which decides the role and the flags.

source MailboxCopySource

The stored message the copy is appended from.

recordIssuedAsync Func<MailFolderResolution, CancellationToken, Task>

Commits the caller's record that an append is about to be issued into the resolved folder.

recordConfirmedAsync Func<AppendedMailCopy, Task>

Commits the caller's record of what the server said, which runs outside the caller's cancellation.

cancellationToken CancellationToken

Cancels everything up to and including the append.

Returns

Task<MailboxCopyAppendResult>

What the server said about the copy, or the reason nothing was appended.

Remarks

A caller that stops before the issued write gets an OperationCanceledException and no APPEND issued, so the next pass files the copy as though this attempt had never started. That says nothing about whether the server was reached: a stop while the session is opening can arrive after the connection, the authentication, or the folder selection, none of which leaves anything in the folder. Past the issued write nothing is raised, because a shutdown there says nothing about a command that may be in flight.

Exceptions

ArgumentNullException

Thrown when source, recordIssuedAsync, or recordConfirmedAsync is null.

ArgumentException

Thrown when filing is the unspecified struct default.