DownloadAttachments
Downloads one or more attachments from an email message, allowing downstream processing or archival of the retrieved files.
Input
| Name | Type | Required | Accepts Output Streams | Description |
| AttachmentSource | String | True | False | Specifies the source object from which to retrieve the attachment. Allowed values are 'Message' for emails or 'Event' for calendar items. |
| SourceId | String | True | False | The unique identifier of the source email or calendar event containing the attachment(s) to be downloaded. |
| AttachmentId | String | False | False | The unique identifier of a specific attachment to be downloaded. If omitted, all attachments from the source item will be downloaded. Not required if 'DownloadInEmlFormat' is specified. |
| DownloadTo | String | False | False | The file system path where the attachment(s) should be saved. If not provided, the attachment content is returned as binary in the output. |
| UserId | String | False | False | The identifier of the impersonated user under whose authority the operation is executed. Used in delegated access scenarios. |
| DownloadInEmlFormat | String | False | False | Indicates whether the attachment should be downloaded in .eml format, which includes MIME headers and original message formatting.
The default value is false. |
| FileStream | String | False | True | An output stream object where attachment data will be written. Used only if 'DownloadTo' is not specified, allowing programmatic access to binary data. |
| Encoding | String | False | False | Specifies the character encoding type used for decoding the content bytes (for example, UTF-8 or Base64).
The allowed values are NONE, BASE64. The default value is BASE64. |
Result Set Columns
| Name | Type | Description |
| Id | String | The unique identifier of the attachment that was successfully downloaded. |
| Name | String | The name or filename of the downloaded attachment, as it will appear when saved or viewed by the user. |
| ContentBytes | String | The raw content of the downloaded attachment, typically returned as a Base64-encoded binary string if not saved to disk. |
| LastmodifiedDatetime | String | The date and time when the attachment was last modified. Useful for version tracking and synchronization. |
| ContentType | String | The MIME content type of the attachment (for example, application/pdf, image/png). This field is null if 'DownloadTo' is specified. |