I am trying to "clone" a message from a user's mailbox to create a copy in a different mailbox. I could successfully use "create message" API by "cloning" a messages's parts into new message including attachments. However, considering 4MB limitation on REST payload, messages that are with larger than 4MB are rejected. So, wondering if there is a way to include attachment by attachment id or contentId instead of downloading and uploading as the attachment is already available on the server.
1
votes
2 Answers
0
votes
According to your description, I assume you want to add attachment to a message.
Based on my test, we can use this API to implement it.
'POST /users/{id | userPrincipalName}/messages/{id}/attachments'
The request body is a JSON representation of Attachment object like this:
{
"contentType": "string",
"id": "string (identifier)", // attachment id
"isInline": true,
"lastModifiedDateTime": "String (timestamp)",
"name": "string",
"size": 1024
}
For more detail, we can refer to this document.
0
votes
Just in case you have not found the answer.
Using the Microsoft Graph API, you can attach files up to 150 MB to an Outlook message or event item. Depending on the file size, choose one of two ways to attach the file:
- If the file size is under 3 MB, do a single POST on the attachments navigation property of the Outlook item; see how to do this for a message or for an event. The successful POST response includes the ID of the file attachment.
- If the file size is between 3MB and 150MB, create an upload session, and iteratively use PUT to upload ranges of bytes of the file until you have uploaded the entire file. A header in the final successful PUT response includes a URL with the attachment ID.
Please refer to this article for more details: https://docs.microsoft.com/en-us/graph/outlook-large-attachments?tabs=http