Table of Contents

Method OpenForReaderAsync

Namespace
MailFathom.Application.Emails.DownloadAttachment
Assembly
MailFathom.Application.dll

OpenForReaderAsync(StoredEmailId, int, CancellationToken)

Opens one attachment for a caller that authenticated and holds the mailbox read grant.

public Task<AttachmentDownloadOutcome> OpenForReaderAsync(StoredEmailId storedEmailId, int attachmentPosition, CancellationToken cancellationToken)

Parameters

storedEmailId StoredEmailId

The email whose attachment to open, as a read of that email published it.

attachmentPosition int

The attachment's zero-based position in the order a read of that email lists them.

cancellationToken CancellationToken

Cancels the read when the reader disconnects.

Returns

Task<AttachmentDownloadOutcome>

The opened attachment, which the caller owns and must dispose, or what refused it.

Remarks

Both values arrive from the caller rather than from a signature this deployment wrote, so neither is trusted: the email is resolved against the accounts the caller's user owns and the folders a read may reach, and the position is what the message's own walk answers for or does not. That is the same resolution the signed path runs, which is why a position naming nothing is a refusal here rather than a validation failure.

The grant is asked for here rather than only at the transport, so an entrypoint added later cannot reach an attachment by forgetting a filter. It is the same grant reading the message itself is published under, because a file the sender attached is part of the message a reader already holds rather than a wider disclosure.

Exceptions

PrincipalNotAuthorizedException

Thrown when the use case was reached by anything but a caller granted MailRead.