How to get the latest email with its attachment in single response using Graph API ?

Yabesh 0 Reputation points
2024-06-12T07:49:30.2933333+00:00

How to get latest mail with its attachment, but in the response its coming all the conversations inside the email, even i select the latest conversation also the full email conversation is coming inside the body as a html, Is there any way to fetch the latest mail and its attachment likewise we get in the mail.?

        # Get the latest conversation
        headers = {
            'Authorization': f'Bearer {access_token}',
            'Content-Type': 'application/json'
        }
        conversations_url = 'https://graph.microsoft.com/v1.0/me/mailFolders/inbox/messages?$top=1&$orderby=receivedDateTime desc'
        conversations_r = requests.get(conversations_url, headers=headers)
Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
11,200 questions
Outlook Management
Outlook Management
Outlook: A family of Microsoft email and calendar products.Management: The act or process of organizing, handling, directing or controlling something.
5,028 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Sourabh Gupta 795 Reputation points Microsoft Vendor
    2024-06-16T09:57:26.03+00:00

    Hi Yabesh,

    Thanks for reaching out.

    You can use the expand on attachments property by using $expand as well.

    For more details you can also refer to the following link as well

    https://learn.microsoft.com/en-us/answers/questions/1381248/how-to-get-all-emails-with-attachement-and-its-con


  2. Sourabh Gupta 795 Reputation points Microsoft Vendor
    2024-06-16T10:01:04.72+00:00

    Hi Yabesh,

    Thanks for reaching out.

    You can use the $expand thing on attachments property to get all the attachment details in one single request.

    This has been explained in more detail at following link.

    https://learn.microsoft.com/en-us/answers/questions/1381248/how-to-get-all-emails-with-attachement-and-its-con