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
accountMailAccountIdThe account whose folder the copy goes into.
filingOutgoingMailFilingWhich place the copy goes into, which decides the role and the flags.
sourceMailboxCopySourceThe stored message the copy is appended from.
recordIssuedAsyncFunc<MailFolderResolution, CancellationToken, Task>Commits the caller's record that an append is about to be issued into the resolved folder.
recordConfirmedAsyncFunc<AppendedMailCopy, Task>Commits the caller's record of what the server said, which runs outside the caller's cancellation.
cancellationTokenCancellationTokenCancels 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, orrecordConfirmedAsyncis null.- ArgumentException
Thrown when
filingis the unspecified struct default.