Retrieving list item attachment and using Outlook REST endpoint to send email with file attachment

Published May 01 2019 04:08 PM 273 Views
Microsoft

First published on TECHNET on Dec 14, 2017
This post is a contribution from Manish Joshi, an engineer with the SharePoint Developer Support team

The purpose of this blog is to walk through the process of calling the Outlook Mail API to send messages in Office 365 and Outlook.com. These guide focuses on the OAuth and REST requests and responses. It will cover the sequence of requests and responses that an app can use to authenticate and send an email messages with file attached from a SharePoint Online list item.

Authentication is covered under:

https://docs.microsoft.com/en-us/outlook/rest/get-started

Note : The outlook endpoint used in this guide https://outlook.office.com/api/beta is beta endpoint and should not be used in Production.

The following sections demonstrate sending an email with attachment from SharePoint Online using the Outlook REST Endpoint. This involves 3 steps which are listed below.



POSTMAN calls :

Step 1: Creating an email message

This is a POST request to the endpoint https://outlook.office.com/api/v2.0/me/MailFolders/inbox/messages . The body of the request will contain details like subject, email body and recipient email address. Note the Id returned in the response. This will be used for subsequent requests.



POST:

https://outlook.office.com/api/v2.0/me/MailFolders/inbox/messages

Body:



{

"Subject": "Did you see last night's game?",

"Importance": "Low",

"Body": {

"ContentType": "HTML",

"Content": "They were <b>awesome</b>!"

},

"ToRecipients": [

{

"EmailAddress": {

"Address": "garthf@spo.onmicrosoft.com"

}

}

]

}


Status:

201 Created

Response:



{

"@odata.context": "https://outlook.office.com/api/v2.0/$metadata#Me/MailFolders('inbox')/Messages/$entity",

"@odata.id": "https://outlook.office.com/api/v2.0/Users('aaaa2e55-386a-4226-817b-c774a83bbbde@d6f932a7-5f74-41ed-8...')",

"@odata.etag": "W/\"CQAAABYAAAD4u6EvSxjoRYdXUVukcUWEAAPywecn\"",

"Id": "AQMkADcwMzljMTUzLTJlMDktNGFiNy1hYzUwLWU5OGYzNzZiMWY1MABGAAADKqbIbNdyOUuJz-wQyvCCegcA_LuhL0sY6EWHV1FbpHFFhAAAAgENAAAA_LuhL0sY6EWHV1FbpHFFhAAD8kJ2LgAAAA==",

"CreatedDateTime": "2017-10-24T23:11:27Z",

"LastModifiedDateTime": "2017-10-24T23:11:27Z",

"ChangeKey": "CQAAABYAAAD4u6EvSxjoRYdXUVukcUWEAAPywecn",

"Categories": [],

"ReceivedDateTime": "2017-10-24T23:11:27Z",

"SentDateTime": "2017-10-24T23:11:27Z",

"HasAttachments": false,

"InternetMessageId": "<CO1PR04MB553B61033EB47364785F9EBF6470@CO1PR04MB553.namprd04.prod.outlook.com>",

"Subject": "Did you see last night's game?",

"BodyPreview": "They were awesome!",

"Importance": "Low",

"ParentFolderId": "AQMkADcwMzljMTUzLTJlMDktNGFiNy1hYzUwLWU5OGYzNzZiMWY1MAAuAAADKqbIbNdyOUuJz-wQyvCCegEA_LuhL0sY6EWHV1FbpHFFhAAAAgENAAAA",

"ConversationId": "AAQkADcwMzljMTUzLTJlMDktNGFiNy1hYzUwLWU5OGYzNzZiMWY1MAAQAEp5UbZ0wvtDnnmReZjdsPc=",

"IsDeliveryReceiptRequested": false,

"IsReadReceiptRequested": false,

"IsRead": true,

"IsDraft": true,

"WebLink": "https://outlook.office365.com/owa/?ItemID=AQMkADcwMzljMTUzLTJlMDktNGFiNy1hYzUwLWU5OGYzNzZiMWY1MABGAA...",

"InferenceClassification": "Focused",

"Body": {

"ContentType": "HTML",

"Content": "<html>\r\n<head>\r\n<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">\r\n<meta content=\"text/html; charset=us-ascii\">\r\n</head>\r\n<body>\r\nThey were <b>awesome</b>!\r\n</body>\r\n</html>\r\n"

},

"ToRecipients": [

{

"EmailAddress": {

"Name": "Garth Fort",

"Address": "GarthF@spo.onmicrosoft.com"

}

}

],

"CcRecipients": [],

"BccRecipients": [],

"ReplyTo": []

}




Step 2: Adding an Attachment to the previously created email

This is a post request to the endpoint https://outlook.office.com/api/beta/me/messages/<<messageID>>/attachments . <<messageID>> is the ID retrieved from Step 1. The body of the request will contain the path of the file In SPO/ODB to be attached.

POST:

https://outlook.office.com/api/beta/me/messages/ AQMkADcwMzljMTUzLTJlMDktNGFiNy1hYzUwLWU5OGYzNzZiMWY1MABGAAADKqbIbNdyOUuJz-wQyvCCegcA_LuhL0sY6EWHV1FbpHFFhAAAAgENAAAA_LuhL0sY6EWHV1FbpHFFhAAD8kJ2LgAAAA==/ attachments

Body:



{

"@odata.type": "#Microsoft.OutlookServices.ReferenceAttachment",

"Name": "Test1.txt",

"SourceUrl": "https://spo.sharepoint.com/sites/TestSite11/Lists/MarketPlace/Attachments/1/Test1.txt",

"ProviderType": "other",

"Permission": "Edit",

"IsFolder": "False"

}


Status:

201 Created

Response:



{

"@odata.context": "https://outlook.office.com/api/beta/$metadata#Me/Messages('AQMkADcwMzljMTUzLTJlMDktNGFiNy1hYzUwLWU5O...",

"@odata.type": "#Microsoft.OutlookServices.ReferenceAttachment",

"@odata.id": "https://outlook.office.com/api/beta/Users('faaa2e55-386a-4226-817b-c774a83bbbde@d6f932a7-5f74-41ed-8...')",

"Id": "AQMkADcwMzljMTUzLTJlMDktNGFiNy1hYzUwLWU5OGYzNzZiMWY1MABGAAADKqbIbNdyOUuJz-wQyvCCegcA_LuhL0sY6EWHV1FbpHFFhAAAAgENAAAA_LuhL0sY6EWHV1FbpHFFhAAD8kJ2LgAAAAESABAAJmVbtRdmnUu74pWlPdmpgA==",

"LastModifiedDateTime": "2017-10-24T23:12:03Z",

"Name": "Test1.txt",

"ContentType": "text/plain",

"Size": 362,

"IsInline": true,

"SourceUrl": "https://spo.sharepoint.com/sites/TestSite11/Lists/MarketPlace/Attachments/1/Test1.txt",

"ProviderType": "Other",

"ThumbnailUrl": null,

"PreviewUrl": null,

"Permission": "Edit",

"IsFolder": false

}




Step 3: Sending the email

The previous two steps involved creating an email message and adding an attachment. The final step is to send the email message. This is a post request to the endpoint https://outlook.office.com/api/beta/me/messages/<<messageID>>/send . The request and response body are empty in this case. The status will be "202 Accepted" if the email message has been successfully sent

POST:

https://outlook.office.com/api/beta/me/messages/ AQMkADcwMzljMTUzLTJlMDktNGFiNy1hYzUwLWU5OGYzNzZiMWY1MABGAAADKqbIbNdyOUuJz-wQyvCCegcA_LuhL0sY6EWHV1FbpHFFhAAAAgENAAAA_LuhL0sY6EWHV1FbpHFFhAAD8kJ2LgAAAA== /send

Body:

Status:

202 Accepted

Response:

%3CLINGO-SUB%20id%3D%22lingo-sub-510028%22%20slang%3D%22en-US%22%3ERetrieving%20list%20item%20attachment%20and%20using%20Outlook%20REST%20endpoint%20to%20send%20email%20with%20file%20attachment%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-510028%22%20slang%3D%22en-US%22%3E%3CP%3E%3CSTRONG%3EFirst%20published%20on%20TECHNET%20on%20Dec%2014%2C%202017%20%3C%2FSTRONG%3E%20%3CBR%20%2F%3EThis%20post%20is%20a%20contribution%20from%20Manish%20Joshi%2C%20an%20engineer%20with%20the%20SharePoint%20Developer%20Support%20team%20%3CBR%20%2F%3E%3CBR%20%2F%3EThe%20purpose%20of%20this%20blog%26nbsp%3Bis%20to%20walk%20through%20the%20process%20of%20calling%20the%20%3CA%20href%3D%22https%3A%2F%2Fdeveloper.microsoft.com%2Fen-us%2Fgraph%2Fdocs%2Fapi-reference%2Fv1.0%2Fresources%2Fmessage%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3E%20Outlook%20Mail%20API%20%3C%2FA%3E%20to%20send%20messages%20in%20Office%20365%20and%20Outlook.com.%20These%20guide%20focuses%20on%20the%20OAuth%20and%20REST%20requests%20and%20responses.%20It%20will%20cover%20the%20sequence%20of%20requests%20and%20responses%20that%20an%20app%20can%20use%20to%20authenticate%20and%20send%20an%20email%20messages%20with%20file%20attached%20from%20a%20SharePoint%20Online%20list%20item.%20%3CBR%20%2F%3E%3CBR%20%2F%3E%20%3CSTRONG%3EAuthentication%20is%20covered%20under%3A%20%3C%2FSTRONG%3E%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Foutlook%2Frest%2Fget-started%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3E%20https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Foutlook%2Frest%2Fget-started%20%3C%2FA%3E%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CSTRONG%3E%20Note%20%3C%2FSTRONG%3E%20%3A%20The%20outlook%20endpoint%20used%20in%20this%20guide%20%3CA%20href%3D%22https%3A%2F%2Foutlook.office.com%2Fapi%2Fbeta%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3E%20https%3A%2F%2Foutlook.office.com%2Fapi%2Fbeta%20%3C%2FA%3E%20is%20beta%20endpoint%20and%20should%20not%20be%20used%20in%20Production.%20%3CBR%20%2F%3E%3CBR%20%2F%3EThe%20following%20sections%20demonstrate%20sending%20an%20email%20with%20attachment%20from%20SharePoint%20Online%20using%20the%20Outlook%20REST%20Endpoint.%20This%20involves%203%20steps%20which%20are%20listed%20below.%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%20%3CSTRONG%3EPOSTMAN%20calls%20%3C%2FSTRONG%3E%20%3A%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CSTRONG%3E%20Step%201%3A%20Creating%20an%20email%20message%20%3C%2FSTRONG%3E%20%3CBR%20%2F%3E%3CBR%20%2F%3EThis%20is%20a%20POST%20request%20to%20the%20endpoint%20%3CA%20href%3D%22https%3A%2F%2Foutlook.office.com%2Fapi%2Fv2.0%2Fme%2FMailFolders%2Finbox%2Fmessages%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3E%20https%3A%2F%2Foutlook.office.com%2Fapi%2Fv2.0%2Fme%2FMailFolders%2Finbox%2Fmessages%20%3C%2FA%3E%20.%20The%20body%20of%20the%20request%20will%20contain%20details%20like%20subject%2C%20email%20body%20and%20recipient%20email%20address.%20Note%20the%20Id%20returned%20in%20the%20response.%20This%20will%20be%20used%20for%20subsequent%20requests.%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3EPOST%3A%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CA%20href%3D%22https%3A%2F%2Foutlook.office.com%2Fapi%2Fv2.0%2Fme%2FMailFolders%2Finbox%2Fmessages%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Ehttps%3A%2F%2Foutlook.office.com%2Fapi%2Fv2.0%2Fme%2FMailFolders%2Finbox%2Fmessages%3C%2FA%3E%20%3CBR%20%2F%3E%3CBR%20%2F%3EBody%3A%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FP%3E%0A%3CDIV%3E%3CBR%20%2F%3E%7B%20%3CBR%20%2F%3E%3CBR%20%2F%3E%22Subject%22%3A%20%22Did%20you%20see%20last%20night's%20game%3F%22%2C%20%3CBR%20%2F%3E%3CBR%20%2F%3E%22Importance%22%3A%20%22Low%22%2C%20%3CBR%20%2F%3E%3CBR%20%2F%3E%22Body%22%3A%20%7B%20%3CBR%20%2F%3E%3CBR%20%2F%3E%22ContentType%22%3A%20%22HTML%22%2C%20%3CBR%20%2F%3E%3CBR%20%2F%3E%22Content%22%3A%20%22They%20were%20%3CB%3Eawesome%3C%2FB%3E!%22%20%3CBR%20%2F%3E%3CBR%20%2F%3E%7D%2C%20%3CBR%20%2F%3E%3CBR%20%2F%3E%22ToRecipients%22%3A%20%5B%20%3CBR%20%2F%3E%3CBR%20%2F%3E%7B%20%3CBR%20%2F%3E%3CBR%20%2F%3E%22EmailAddress%22%3A%20%7B%20%3CBR%20%2F%3E%3CBR%20%2F%3E%22Address%22%3A%20%22garthf%40spo.onmicrosoft.com%22%20%3CBR%20%2F%3E%3CBR%20%2F%3E%7D%20%3CBR%20%2F%3E%3CBR%20%2F%3E%7D%20%3CBR%20%2F%3E%3CBR%20%2F%3E%5D%20%3CBR%20%2F%3E%3CBR%20%2F%3E%7D%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FDIV%3E%0A%3CP%3E%3CBR%20%2F%3EStatus%3A%20%3CBR%20%2F%3E%3CBR%20%2F%3E201%20Created%20%3CBR%20%2F%3E%3CBR%20%2F%3EResponse%3A%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FP%3E%0A%3CDIV%3E%3CBR%20%2F%3E%7B%20%3CBR%20%2F%3E%3CBR%20%2F%3E%22%40odata.context%22%3A%20%22%3CA%20href%3D%22https%3A%2F%2Foutlook.office.com%2Fapi%2Fv2.0%2F%24metadata%23Me%2FMailFolders('inbox')%2FMessages%2F%24entity%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Ehttps%3A%2F%2Foutlook.office.com%2Fapi%2Fv2.0%2F%24metadata%23Me%2FMailFolders('inbox')%2FMessages%2F%24entity%3C%2FA%3E%22%2C%20%3CBR%20%2F%3E%3CBR%20%2F%3E%22%40odata.id%22%3A%20%22%3CA%20href%3D%22https%3A%2F%2Foutlook.office.com%2Fapi%2Fv2.0%2FUsers('aaaa2e55-386a-4226-817b-c774a83bbbde%40d6f932a7-5f74-41ed-8d92-b27004970770')%2FMessages('AQMkADcwMzljMTUzLTJlMDktNGFiNy1hYzUwLWU5OGYzNzZiMWY1MABGAAADKqbIbNdyOUuJz-wQyvCCegcA_LuhL0sY6EWHV1FbpHFFhAAAAgENAAAA_LuhL0sY6EWHV1FbpHFFhAAD8kJ2LgAAAA%3D%3D%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Ehttps%3A%2F%2Foutlook.office.com%2Fapi%2Fv2.0%2FUsers('aaaa2e55-386a-4226-817b-c774a83bbbde%40d6f932a7-5f74-41ed-8d92-b27004970770')%2FMessages('AQMkADcwMzljMTUzLTJlMDktNGFiNy1hYzUwLWU5OGYzNzZiMWY1MABGAAADKqbIbNdyOUuJz-wQyvCCegcA_LuhL0sY6EWHV1FbpHFFhAAAAgENAAAA_LuhL0sY6EWHV1FbpHFFhAAD8kJ2LgAAAA%3D%3D%3C%2FA%3E')%22%2C%20%3CBR%20%2F%3E%3CBR%20%2F%3E%22%40odata.etag%22%3A%20%22W%2F%5C%22CQAAABYAAAD4u6EvSxjoRYdXUVukcUWEAAPywecn%5C%22%22%2C%20%3CBR%20%2F%3E%3CBR%20%2F%3E%22Id%22%3A%20%22AQMkADcwMzljMTUzLTJlMDktNGFiNy1hYzUwLWU5OGYzNzZiMWY1MABGAAADKqbIbNdyOUuJz-wQyvCCegcA_LuhL0sY6EWHV1FbpHFFhAAAAgENAAAA_LuhL0sY6EWHV1FbpHFFhAAD8kJ2LgAAAA%3D%3D%22%2C%20%3CBR%20%2F%3E%3CBR%20%2F%3E%22CreatedDateTime%22%3A%20%222017-10-24T23%3A11%3A27Z%22%2C%20%3CBR%20%2F%3E%3CBR%20%2F%3E%22LastModifiedDateTime%22%3A%20%222017-10-24T23%3A11%3A27Z%22%2C%20%3CBR%20%2F%3E%3CBR%20%2F%3E%22ChangeKey%22%3A%20%22CQAAABYAAAD4u6EvSxjoRYdXUVukcUWEAAPywecn%22%2C%20%3CBR%20%2F%3E%3CBR%20%2F%3E%22Categories%22%3A%20%5B%5D%2C%20%3CBR%20%2F%3E%3CBR%20%2F%3E%22ReceivedDateTime%22%3A%20%222017-10-24T23%3A11%3A27Z%22%2C%20%3CBR%20%2F%3E%3CBR%20%2F%3E%22SentDateTime%22%3A%20%222017-10-24T23%3A11%3A27Z%22%2C%20%3CBR%20%2F%3E%3CBR%20%2F%3E%22HasAttachments%22%3A%20false%2C%20%3CBR%20%2F%3E%3CBR%20%2F%3E%22InternetMessageId%22%3A%20%22%3CCO1PR04MB553B61033EB47364785F9EBF6470%3E%22%2C%20%3CBR%20%2F%3E%3CBR%20%2F%3E%22Subject%22%3A%20%22Did%20you%20see%20last%20night's%20game%3F%22%2C%20%3CBR%20%2F%3E%3CBR%20%2F%3E%22BodyPreview%22%3A%20%22They%20were%20awesome!%22%2C%20%3CBR%20%2F%3E%3CBR%20%2F%3E%22Importance%22%3A%20%22Low%22%2C%20%3CBR%20%2F%3E%3CBR%20%2F%3E%22ParentFolderId%22%3A%20%22AQMkADcwMzljMTUzLTJlMDktNGFiNy1hYzUwLWU5OGYzNzZiMWY1MAAuAAADKqbIbNdyOUuJz-wQyvCCegEA_LuhL0sY6EWHV1FbpHFFhAAAAgENAAAA%22%2C%20%3CBR%20%2F%3E%3CBR%20%2F%3E%22ConversationId%22%3A%20%22AAQkADcwMzljMTUzLTJlMDktNGFiNy1hYzUwLWU5OGYzNzZiMWY1MAAQAEp5UbZ0wvtDnnmReZjdsPc%3D%22%2C%20%3CBR%20%2F%3E%3CBR%20%2F%3E%22IsDeliveryReceiptRequested%22%3A%20false%2C%20%3CBR%20%2F%3E%3CBR%20%2F%3E%22IsReadReceiptRequested%22%3A%20false%2C%20%3CBR%20%2F%3E%3CBR%20%2F%3E%22IsRead%22%3A%20true%2C%20%3CBR%20%2F%3E%3CBR%20%2F%3E%22IsDraft%22%3A%20true%2C%20%3CBR%20%2F%3E%3CBR%20%2F%3E%22WebLink%22%3A%20%22%3CA%20href%3D%22https%3A%2F%2Foutlook.office365.com%2Fowa%2F%3FItemID%3DAQMkADcwMzljMTUzLTJlMDktNGFiNy1hYzUwLWU5OGYzNzZiMWY1MABGAAADKqbIbNdyOUuJz%252FwQyvCCegcA%252BLuhL0sY6EWHV1FbpHFFhAAAAgENAAAA%252BLuhL0sY6EWHV1FbpHFFhAAD8kJ2LgAAAA%253D%253D%26amp%3Bexvsurl%3D1%26amp%3Bviewmodel%3DReadMessageItem%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noreferrer%22%3Ehttps%3A%2F%2Foutlook.office365.com%2Fowa%2F%3FItemID%3DAQMkADcwMzljMTUzLTJlMDktNGFiNy1hYzUwLWU5OGYzNzZiMWY1MABGAAADKqbIbNdyOUuJz%252FwQyvCCegcA%252BLuhL0sY6EWHV1FbpHFFhAAAAgENAAAA%252BLuhL0sY6EWHV1FbpHFFhAAD8kJ2LgAAAA%253D%253D%26amp%3Bexvsurl%3D1%26amp%3Bviewmodel%3DReadMessageItem%3C%2FA%3E%22%2C%20%3CBR%20%2F%3E%3CBR%20%2F%3E%22InferenceClassification%22%3A%20%22Focused%22%2C%20%3CBR%20%2F%3E%3CBR%20%2F%3E%22Body%22%3A%20%7B%20%3CBR%20%2F%3E%3CBR%20%2F%3E%22ContentType%22%3A%20%22HTML%22%2C%20%3CBR%20%2F%3E%3CBR%20%2F%3E%22Content%22%3A%20%22%5Cr%5Cn%5Cr%5Cn%26lt%3Bmeta%20http-equiv%3D%22%5C%22Content-Type%5C%22%22%20content%3D%22%5C%22text%2Fhtml%3B%22%20charset%3D%22utf-8%5C%22%22%20%2F%26gt%3B%5Cr%5Cn%26lt%3Bmeta%20content%3D%22%5C%22text%2Fhtml%3B%22%20charset%3D%22us-ascii%5C%22%22%20%2F%26gt%3B%5Cr%5Cn%5Cr%5Cn%5Cr%5CnThey%20were%20%3CB%3Eawesome%3C%2FB%3E!%5Cr%5Cn%5Cr%5Cn%5Cr%5Cn%22%20%3CBR%20%2F%3E%3CBR%20%2F%3E%7D%2C%20%3CBR%20%2F%3E%3CBR%20%2F%3E%22ToRecipients%22%3A%20%5B%20%3CBR%20%2F%3E%3CBR%20%2F%3E%7B%20%3CBR%20%2F%3E%3CBR%20%2F%3E%22EmailAddress%22%3A%20%7B%20%3CBR%20%2F%3E%3CBR%20%2F%3E%22Name%22%3A%20%22Garth%20Fort%22%2C%20%3CBR%20%2F%3E%3CBR%20%2F%3E%22Address%22%3A%20%22GarthF%40spo.onmicrosoft.com%22%20%3CBR%20%2F%3E%3CBR%20%2F%3E%7D%20%3CBR%20%2F%3E%3CBR%20%2F%3E%7D%20%3CBR%20%2F%3E%3CBR%20%2F%3E%5D%2C%20%3CBR%20%2F%3E%3CBR%20%2F%3E%22CcRecipients%22%3A%20%5B%5D%2C%20%3CBR%20%2F%3E%3CBR%20%2F%3E%22BccRecipients%22%3A%20%5B%5D%2C%20%3CBR%20%2F%3E%3CBR%20%2F%3E%22ReplyTo%22%3A%20%5B%5D%20%3CBR%20%2F%3E%3CBR%20%2F%3E%7D%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FCO1PR04MB553B61033EB47364785F9EBF6470%3E%3C%2FDIV%3E%0A%3CP%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%20%3CSTRONG%3EStep%202%3A%20Adding%20an%20Attachment%20to%20the%20previously%20created%20email%20%3C%2FSTRONG%3E%20%3CBR%20%2F%3E%3CBR%20%2F%3EThis%20is%20a%20post%20request%20to%20the%20endpoint%20%3CA%20href%3D%22https%3A%2F%2Foutlook.office.com%2Fapi%2Fbeta%2Fme%2Fmessages%2F%253c%253cmessageID%253e%253e%2Fattachments%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3E%20https%3A%2F%2Foutlook.office.com%2Fapi%2Fbeta%2Fme%2Fmessages%2F%26lt%3B%3CMESSAGEID%3E%26gt%3B%2Fattachments%20%3C%2FMESSAGEID%3E%3C%2FA%3E%20.%20%26lt%3B%3CMESSAGEID%3E%26gt%3B%20is%20the%20ID%20retrieved%20from%20Step%201.%20The%20body%20of%20the%20request%20will%20contain%20the%20path%20of%20the%20file%20In%20SPO%2FODB%20to%20be%20attached.%20%3CBR%20%2F%3E%3CBR%20%2F%3EPOST%3A%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CA%20href%3D%22https%3A%2F%2Foutlook.office.com%2Fapi%2Fbeta%2Fme%2Fmessages%2F%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Ehttps%3A%2F%2Foutlook.office.com%2Fapi%2Fbeta%2Fme%2Fmessages%2F%3C%2FA%3E%20%3CSTRONG%3E%20AQMkADcwMzljMTUzLTJlMDktNGFiNy1hYzUwLWU5OGYzNzZiMWY1MABGAAADKqbIbNdyOUuJz-wQyvCCegcA_LuhL0sY6EWHV1FbpHFFhAAAAgENAAAA_LuhL0sY6EWHV1FbpHFFhAAD8kJ2LgAAAA%3D%3D%2F%20%3C%2FSTRONG%3E%20attachments%20%3CBR%20%2F%3E%3CBR%20%2F%3EBody%3A%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FMESSAGEID%3E%3C%2FP%3E%0A%3CDIV%3E%3CBR%20%2F%3E%7B%20%3CBR%20%2F%3E%3CBR%20%2F%3E%22%40odata.type%22%3A%20%22%23Microsoft.OutlookServices.ReferenceAttachment%22%2C%20%3CBR%20%2F%3E%3CBR%20%2F%3E%22Name%22%3A%20%22Test1.txt%22%2C%20%3CBR%20%2F%3E%3CBR%20%2F%3E%22SourceUrl%22%3A%20%22%3CA%20href%3D%22https%3A%2F%2Fspo.sharepoint.com%2Fsites%2FTestSite11%2FLists%2FMarketPlace%2FAttachments%2F1%2FTest1.txt%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noreferrer%22%3Ehttps%3A%2F%2Fspo.sharepoint.com%2Fsites%2FTestSite11%2FLists%2FMarketPlace%2FAttachments%2F1%2FTest1.txt%3C%2FA%3E%22%2C%20%3CBR%20%2F%3E%3CBR%20%2F%3E%22ProviderType%22%3A%20%22other%22%2C%20%3CBR%20%2F%3E%3CBR%20%2F%3E%22Permission%22%3A%20%22Edit%22%2C%20%3CBR%20%2F%3E%3CBR%20%2F%3E%22IsFolder%22%3A%20%22False%22%20%3CBR%20%2F%3E%3CBR%20%2F%3E%7D%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FDIV%3E%0A%3CP%3E%3CBR%20%2F%3EStatus%3A%20%3CBR%20%2F%3E%3CBR%20%2F%3E201%20Created%20%3CBR%20%2F%3E%3CBR%20%2F%3EResponse%3A%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FP%3E%0A%3CDIV%3E%3CBR%20%2F%3E%7B%20%3CBR%20%2F%3E%3CBR%20%2F%3E%22%40odata.context%22%3A%20%22%3CA%20href%3D%22https%3A%2F%2Foutlook.office.com%2Fapi%2Fbeta%2F%24metadata%23Me%2FMessages('AQMkADcwMzljMTUzLTJlMDktNGFiNy1hYzUwLWU5OGYzNzZiMWY1MABGAAADKqbIbNdyOUuJz-wQyvCCegcA_LuhL0sY6EWHV1FbpHFFhAAAAgENAAAA_LuhL0sY6EWHV1FbpHFFhAAD8kJ2LgAAAA%253D%253D')%2FAttachments%2F%24entity%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Ehttps%3A%2F%2Foutlook.office.com%2Fapi%2Fbeta%2F%24metadata%23Me%2FMessages('AQMkADcwMzljMTUzLTJlMDktNGFiNy1hYzUwLWU5OGYzNzZiMWY1MABGAAADKqbIbNdyOUuJz-wQyvCCegcA_LuhL0sY6EWHV1FbpHFFhAAAAgENAAAA_LuhL0sY6EWHV1FbpHFFhAAD8kJ2LgAAAA%253D%253D')%2FAttachments%2F%24entity%3C%2FA%3E%22%2C%20%3CBR%20%2F%3E%3CBR%20%2F%3E%22%40odata.type%22%3A%20%22%23Microsoft.OutlookServices.ReferenceAttachment%22%2C%20%3CBR%20%2F%3E%3CBR%20%2F%3E%22%40odata.id%22%3A%20%22%3CA%20href%3D%22https%3A%2F%2Foutlook.office.com%2Fapi%2Fbeta%2FUsers('faaa2e55-386a-4226-817b-c774a83bbbde%40d6f932a7-5f74-41ed-8d92-b27004970776')%2FMessages('AQMkADcwMzljMTUzLTJlMDktNGFiNy1hYzUwLWU5OGYzNzZiMWY1MABGAAADKqbIbNdyOUuJz-wQyvCCegcA_LuhL0sY6EWHV1FbpHFFhAAAAgENAAAA_LuhL0sY6EWHV1FbpHFFhAAD8kJ2LgAAAA%3D%3D')%2FAttachments('AQMkADcwMzljMTUzLTJlMDktNGFiNy1hYzUwLWU5OGYzNzZiMWY1MABGAAADKqbIbNdyOUuJz-wQyvCCegcA_LuhL0sY6EWHV1FbpHFFhAAAAgENAAAA_LuhL0sY6EWHV1FbpHFFhAAD8kJ2LgAAAAESABAAJmVbtRdmnUu74pWlPdmpgA%3D%3D%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Ehttps%3A%2F%2Foutlook.office.com%2Fapi%2Fbeta%2FUsers('faaa2e55-386a-4226-817b-c774a83bbbde%40d6f932a7-5f74-41ed-8d92-b27004970776')%2FMessages('AQMkADcwMzljMTUzLTJlMDktNGFiNy1hYzUwLWU5OGYzNzZiMWY1MABGAAADKqbIbNdyOUuJz-wQyvCCegcA_LuhL0sY6EWHV1FbpHFFhAAAAgENAAAA_LuhL0sY6EWHV1FbpHFFhAAD8kJ2LgAAAA%3D%3D')%2FAttachments('AQMkADcwMzljMTUzLTJlMDktNGFiNy1hYzUwLWU5OGYzNzZiMWY1MABGAAADKqbIbNdyOUuJz-wQyvCCegcA_LuhL0sY6EWHV1FbpHFFhAAAAgENAAAA_LuhL0sY6EWHV1FbpHFFhAAD8kJ2LgAAAAESABAAJmVbtRdmnUu74pWlPdmpgA%3D%3D%3C%2FA%3E')%22%2C%20%3CBR%20%2F%3E%3CBR%20%2F%3E%22Id%22%3A%20%22AQMkADcwMzljMTUzLTJlMDktNGFiNy1hYzUwLWU5OGYzNzZiMWY1MABGAAADKqbIbNdyOUuJz-wQyvCCegcA_LuhL0sY6EWHV1FbpHFFhAAAAgENAAAA_LuhL0sY6EWHV1FbpHFFhAAD8kJ2LgAAAAESABAAJmVbtRdmnUu74pWlPdmpgA%3D%3D%22%2C%20%3CBR%20%2F%3E%3CBR%20%2F%3E%22LastModifiedDateTime%22%3A%20%222017-10-24T23%3A12%3A03Z%22%2C%20%3CBR%20%2F%3E%3CBR%20%2F%3E%22Name%22%3A%20%22Test1.txt%22%2C%20%3CBR%20%2F%3E%3CBR%20%2F%3E%22ContentType%22%3A%20%22text%2Fplain%22%2C%20%3CBR%20%2F%3E%3CBR%20%2F%3E%22Size%22%3A%20362%2C%20%3CBR%20%2F%3E%3CBR%20%2F%3E%22IsInline%22%3A%20true%2C%20%3CBR%20%2F%3E%3CBR%20%2F%3E%22SourceUrl%22%3A%20%22%3CA%20href%3D%22https%3A%2F%2Fspo.sharepoint.com%2Fsites%2FTestSite11%2FLists%2FMarketPlace%2FAttachments%2F1%2FTest1.txt%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noreferrer%22%3Ehttps%3A%2F%2Fspo.sharepoint.com%2Fsites%2FTestSite11%2FLists%2FMarketPlace%2FAttachments%2F1%2FTest1.txt%3C%2FA%3E%22%2C%20%3CBR%20%2F%3E%3CBR%20%2F%3E%22ProviderType%22%3A%20%22Other%22%2C%20%3CBR%20%2F%3E%3CBR%20%2F%3E%22ThumbnailUrl%22%3A%20null%2C%20%3CBR%20%2F%3E%3CBR%20%2F%3E%22PreviewUrl%22%3A%20null%2C%20%3CBR%20%2F%3E%3CBR%20%2F%3E%22Permission%22%3A%20%22Edit%22%2C%20%3CBR%20%2F%3E%3CBR%20%2F%3E%22IsFolder%22%3A%20false%20%3CBR%20%2F%3E%3CBR%20%2F%3E%7D%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FDIV%3E%0A%3CP%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%20%3CSTRONG%3EStep%203%3A%20Sending%20the%20email%20%3C%2FSTRONG%3E%20%3CBR%20%2F%3E%3CBR%20%2F%3EThe%20previous%20two%20steps%20involved%20creating%20an%20email%20message%20and%20adding%20an%20attachment.%20The%20final%20step%20is%20to%20send%20the%20email%20message.%20This%20is%20a%20post%20request%20to%20the%20endpoint%20%3CA%20href%3D%22https%3A%2F%2Foutlook.office.com%2Fapi%2Fbeta%2Fme%2Fmessages%2F%26lt%3B%26lt%3BmessageID%26gt%3B%26gt%3B%2Fsend%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3E%20https%3A%2F%2Foutlook.office.com%2Fapi%2Fbeta%2Fme%2Fmessages%2F%26lt%3B%3CMESSAGEID%3E%26gt%3B%2Fsend%20%3C%2FMESSAGEID%3E%3C%2FA%3E%20.%20The%20request%20and%20response%20body%26nbsp%3Bare%20empty%20in%20this%20case.%20The%20status%20will%20be%20%22202%20Accepted%22%20if%20the%20email%20message%20has%20been%20successfully%20sent%20%3CBR%20%2F%3E%3CBR%20%2F%3EPOST%3A%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CA%20href%3D%22https%3A%2F%2Foutlook.office.com%2Fapi%2Fbeta%2Fme%2Fmessages%2F%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Ehttps%3A%2F%2Foutlook.office.com%2Fapi%2Fbeta%2Fme%2Fmessages%2F%3C%2FA%3E%20%3CSTRONG%3E%20AQMkADcwMzljMTUzLTJlMDktNGFiNy1hYzUwLWU5OGYzNzZiMWY1MABGAAADKqbIbNdyOUuJz-wQyvCCegcA_LuhL0sY6EWHV1FbpHFFhAAAAgENAAAA_LuhL0sY6EWHV1FbpHFFhAAD8kJ2LgAAAA%3D%3D%20%3C%2FSTRONG%3E%20%2Fsend%20%3CBR%20%2F%3E%3CBR%20%2F%3EBody%3A%20%3CBR%20%2F%3E%3CBR%20%2F%3EStatus%3A%20%3CBR%20%2F%3E%3CBR%20%2F%3E202%20Accepted%20%3CBR%20%2F%3E%3CBR%20%2F%3EResponse%3A%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-TEASER%20id%3D%22lingo-teaser-510028%22%20slang%3D%22en-US%22%3E%3CP%3EFirst%20published%20on%20TECHNET%20on%20Dec%2014%2C%202017%20This%20post%20is%20a%20contribution%20from%20Manish%20Joshi%2C%20an%20engineer%20with%20the%20SharePoint%20Developer%20Support%20teamThe%20purpose%20of%20this%20blog%26nbsp%3Bis%20to%20walk%20through%20the%20process%20of%20calling%20the%20Outlook%20Mail%20API%20to%20send%20messages%20in%20Office%20365%20and%20Outlook.%3C%2FP%3E%3C%2FLINGO-TEASER%3E%3CLINGO-LABS%20id%3D%22lingo-labs-510028%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EDeveloper%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
Version history
Last update:
‎Sep 01 2020 02:28 PM
Updated by: