Skip to content

Instantly share code, notes, and snippets.

@gscales
Created September 17, 2021 05:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gscales/f97586fe105e3c3316bd8517990e8656 to your computer and use it in GitHub Desktop.
Save gscales/f97586fe105e3c3316bd8517990e8656 to your computer and use it in GitHub Desktop.
Create a Draft message
POST https://graph.microsoft.com/v1.0/users('gscales@.....com')/mailfolders/drafts/messages HTTP/1.1
{
"Subject": "Test Message 1234",
"Body": {
"ContentType": "HTML",
"Content": "Rgds Glen"
},
"ToRecipients": [
{
"EmailAddress": {
"Name": "glenscales@blahlah.com",
"Address": "glenscales@blahlah.com"
}
}
]
}
Create the Attachment
POST https://graph.microsoft.com/v1.0/users('gscales@datarumble.com')/messages/AAMk..../attachments/createUploadSession
{
"AttachmentItem": {
"attachmentType": "file",
"name": "rates.pdf",
"size": 2377002
}
}
Will return
{
"@odata.context": "https://graph.microsoft.com/v1.0/$metadata#microsoft.graph.uploadSession",
"uploadUrl": "https://outlook.office.com/api/gv1.0/users('150bb0...')/messages('AAM...')/AttachmentSessions('AAM...')?authtoken=eyJ....",
"expirationDateTime": "2021-09-17T07:27:44.3599952Z",
"nextExpectedRanges": [
"0-"
]
}
Upload the attachment in chunks
PUT https://outlook.office.com/api/gv1.0/users('150b...4')/messages('AAM...')/AttachmentSessions('AAM....')?authtoken=ey...
Content-Range: bytes 0-399999/2377002
Then Send the draft message
POST https://graph.microsoft.com/v1.0/users('gscales@datarumble.com')/messages/AAM.../send
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment