
Extract attachments from already-fetched messages
Source:R/extract-attachments.R
extract_attachments.RdThe offline half of the attachment family (since the 2026 refactoring):
takes the full text of messages already fetched with
ImapCon$fetch_body(), walks the MIME
multipart tree by its declared boundaries, and either reports the
attachments (dest = NULL) or writes them to disk. It replaces both
list_attachments() (reporting) and
ImapCon$get_attachments() (writing).
Usage
extract_attachments(
msg_list,
dest = NULL,
content_disposition = "both",
override = FALSE,
as_is = FALSE,
mute = FALSE
)Arguments
- msg_list
A
listwith the fetched messages, as returned byImapCon$fetch_body()(the full message, whose headers declare the MIME boundaries). Text-only fetches (fetch_text()) lack those headers and cannot be walked reliably.- dest
NULL(default) to only report: the return value is a namedlistwith onedata.frameper message (filename, content_disposition, type, size; zero rows when a message has no attachments). A directory path writes each message's attachments todest/<message id>/and returns the same manifest invisibly.- content_disposition
One of
"both"(default),"attachment", or"inline".- override
A
logical. IfTRUE, overrides existing files with the same name. Default isFALSE.- as_is
If
TRUE, writes payloads without decoding the transfer encoding. Default isFALSE.- mute
A
logical. IfTRUE, mutes the confirmation message when writing. Default isFALSE.
See also
Other attachments:
ImapCon,
list_attachments()