- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
12-01-22 03:44 PM
Im trying to modify the Outlook Graph API's to include an action that sends an email with an attachment.
From what i can gather from MS own websites, you need to use the following request :
"attachments":
{
"@odata.type": "#microsoft.graph.fileAttachment",
"name": "[Attachment Name]",
"contentBytes": "[ContentBytes]"
}
So what i've attempted to do is add the above to the sendMail API request, getting the following:
However, I keep getting an error "InvalidRecipient", even though im using my own work email as recipient, which works when using the standard sendMail API.
For easier viewability, i've added an attachment of how it looks in graph explorer.
Anyone with any experience doing this?
Thanks.
Br,
Seb
Answered! Go to Answer.
Helpful Answers
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
12-01-22 04:58 PM
Here's an example body template for a version of the Send Mail action that incudes the option for an attachment:
{
"message": {
"subject": "[Subject]",
"body": {
"contentType": "[Email Body Content Type]",
"content": "[Email Body Content]"
},
"toRecipients": [
{
"emailAddress": {
"address": "[Email Address]"
}
}
],
"ccRecipients": [
{
"emailAddress": {
"address": "[Email Address]"
}
}
],
"attachments": [
{
"@odata.type": "#microsoft.graph.fileAttachment",
"name": "[Attachment Name]",
"contentType": "[Attachment Content Type]",
"contentBytes": "[Attachment Contents]"
}
]
},
"saveToSentItems": "[Save to Sent Items Folder]"
}
I believe Microsoft expect to see the recipient information before any attachment sections.
And here's a screenshot of how I set up the input parameters:
Cheers,
Eric
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
12-01-22 04:58 PM
Here's an example body template for a version of the Send Mail action that incudes the option for an attachment:
{
"message": {
"subject": "[Subject]",
"body": {
"contentType": "[Email Body Content Type]",
"content": "[Email Body Content]"
},
"toRecipients": [
{
"emailAddress": {
"address": "[Email Address]"
}
}
],
"ccRecipients": [
{
"emailAddress": {
"address": "[Email Address]"
}
}
],
"attachments": [
{
"@odata.type": "#microsoft.graph.fileAttachment",
"name": "[Attachment Name]",
"contentType": "[Attachment Content Type]",
"contentBytes": "[Attachment Contents]"
}
]
},
"saveToSentItems": "[Save to Sent Items Folder]"
}
I believe Microsoft expect to see the recipient information before any attachment sections.
And here's a screenshot of how I set up the input parameters:
Cheers,
Eric
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
13-01-22 08:04 AM
Br,
Seb
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
08-07-22 03:09 PM
May I ask what should be the
"contentType": "[Attachment Content Type]",
"contentBytes": "[Attachment Contents]"
Do I need some code to get the contentBytes of an attachment?
Also, is this api can upload attachment of more than 4MB size?
Thanks in advance 🙂
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
08-07-22 10:07 PM
Content-Type is the MIME type of the file you’re trying to attach to the email. As an example, if I wanted to attach a PDF to the email I would set the content type to “application/pdf”. You can find a list of common MIME types here.
Content Bytes is the actual binary content of the file attachment. You can get the bytes by using the Calculation stage.
Cheers,
Eric
