Table of Contents

Method CreateForSelection

Namespace
MailFathom.Application.Emails.GetEmailContent
Assembly
MailFathom.Application.dll

CreateForSelection(Func<IReadOnlyList<StoredEmailId>>?, Func<EmailThreadId>?, bool, bool)

Creates a request from the two ways a caller may select what to read, refusing anything but one of them.

public static GetEmailContentRequest CreateForSelection(Func<IReadOnlyList<StoredEmailId>>? namedEmails, Func<EmailThreadId>? namedThread, bool includeSanitizedHtml = false, bool includeAttachmentDownloadLinks = false)

Parameters

namedEmails Func<IReadOnlyList<StoredEmailId>>

Resolves the emails the caller named, or null when it named none.

namedThread Func<EmailThreadId>

Resolves the conversation the caller named, or null when it named none.

includeSanitizedHtml bool

Whether to also produce the sanitized HTML representation of each body.

includeAttachmentDownloadLinks bool

Whether to mint a link for each attachment rather than only describe it.

Returns

GetEmailContentRequest

The validated request.

Remarks

A call carrying both is refused rather than resolved by precedence, because either reading of it returns mail the caller did not ask for: honouring the list ignores a conversation somebody wanted, and honouring the conversation returns messages nobody named. Which one was meant is theirs to say.

Both arrive unresolved, which is what puts that refusal in front of everything either of them is checked for. Whether the caller named one is knowable from the selection alone, while what they named costs a boundary a parse over text it did not choose the length of — so a call this method refuses pays for neither parse, and a caller sending both is told which of the two arguments to drop rather than that the one it never meant to use is too short or misspelled. Resolving either eagerly would put its own failure in front of the refusal, which is the same defect on whichever side it is left.

Exceptions

EmailContentReadSelectionInvalidException

Thrown when both selections are given, or neither is.

EmailContentReadCountOutOfRangeException

Thrown when a named list holds no email, or more than MaximumEmails.

EmailContentReadDuplicateEmailException

Thrown when a named list holds the same email more than once.