Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
11,448 questions
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
The query returns all other data of the message except the body-tag. My application has mail.readwrite authorization.
message_id = "<removed>"
user_email = "<removed>"
access_token = "<removed>"
headers = {
"Authorization": f"Bearer {access_token}"
}
def get_message_details(message_id):
message_url = f"https://graph.microsoft.com/v1.0/users/{user_email}/messages/{message_id}"
query_parameters = {"$select": "from,subject,body"}
response = requests.get(message_url, headers=headers, params=query_parameters)
if response.status_code == 200:
data = response.json()
return data
else:
return None
result = get_message_details(message_id)
print(json.dumps(result, indent=4))
Output:
{ "@odata.context": "<removed>",
"@odata.etag": "<removed>",
"id": "<removed>",
"subject": "Do Taylor Swift and Travis Kelce have blogs on Podia?",
"from": { "emailAddress": { "name": "Spencer from Podia", "address": "create@podia.com" } } }
I have also tried selecting all fields ("*") and still no message body...
I deleted and re-added the permission to MS Graph and re-generated the client secret. Behold now it works (and now I know the truth about the blog 🤩) For some reason i only got BasicRead rights and that does not show the body-part of the messages.