Method SaveMailDraftContentAsync
- Namespace
- MailFathom.Application.EmailContent.Storage
- Assembly
- MailFathom.Application.dll
SaveMailDraftContentAsync(IPersistenceSession, MailDraftId, ReadOnlyMemory<byte>, CancellationToken)
Saves the raw MIME one revision of a draft is held as, replacing whatever the previous revision stored.
Task SaveMailDraftContentAsync(IPersistenceSession session, MailDraftId draftId, ReadOnlyMemory<byte> rawMime, CancellationToken cancellationToken)
Parameters
sessionIPersistenceSessionThe explicit persistence session this content write participates in.
draftIdMailDraftIdThe draft this message is the current revision of.
rawMimeReadOnlyMemory<byte>The composed RFC 822 bytes.
cancellationTokenCancellationTokenPropagates caller cancellation.
Returns
- Task
A task that completes after durable storage.
Remarks
This is the one raw-MIME write in this system that overwrites, and the difference from the outgoing one is the whole reason a draft is not an outgoing record. A send's payload is written once because a retry has to transmit the bytes an earlier attempt may already have begun transmitting; a draft's payload is what its author is still editing, and holding every version of it would keep a message per keystroke for as long as the draft lives.
It joins the caller's session because the payload and the revision it belongs to are one decision: a draft whose row says revision three and whose bytes are revision two is a draft that would be appended wrongly and promoted wrongly, so the two commit together or neither does.
Exceptions
- ArgumentNullException
Thrown when
sessionis null.- ArgumentException
Thrown when
rawMimeis empty.- InvalidOperationException
Thrown when no draft is held under
draftId.