Table of Contents

Method SaveAsync

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

SaveAsync(MailAccountId, OutgoingEmailRequester, ComposedMailDraft, MailDraftId?, CancellationToken)

Writes a composed draft down, as a new one or as the next revision of one that already exists.

public Task<MailDraftRecord> SaveAsync(MailAccountId accountId, OutgoingEmailRequester author, ComposedMailDraft composed, MailDraftId? revises, CancellationToken cancellationToken)

Parameters

accountId MailAccountId

The account the draft belongs to.

author OutgoingEmailRequester

The authored act writing it down.

composed ComposedMailDraft

The composed message, its recipients, and the identity this revision carries.

revises MailDraftId?

The draft this replaces, or null to write a new one.

cancellationToken CancellationToken

Cancels the writes and the commands that follow them.

Returns

Task<MailDraftRecord>

The draft as it stands once the mailbox has been brought into step with it.

Remarks

The revision is durable before any command reaches the mail server, which is what makes a replacement resumable: the record already says which copy is being replaced, so a process that dies between the append and the removal leaves one draft in the folder rather than two or none.

Exceptions

ArgumentNullException

Thrown when author or composed is null.

PrincipalNotAuthorizedException

Thrown when the act the author names is not what reached this.

MailDraftRefusedException

Thrown when revises names no draft of this account that is still being written.

PersistenceConcurrencyConflictException

Thrown when the write did not commit on any allowed attempt.