How to download OneDrive/SharePoint attachments off messages (email) using Graph API?

eggy mcegg 0 Reputation points
2024-07-23T17:34:24.4+00:00

I have a requirement where I have to download the content that is attached to the emails in my organisation.

Scenarios include

  • when a user is on OneDrive/Sharepoint and they go to share a file via email. A 'sent' email gets generated in said users emails.
  • when a user is on Outlook -> New message -> Attach file -> OneDrive -> Send. A 'sent' email gets generated in said users emails.

I can access these emails, but the problem is I am unable to download the actual content. For instance the attachments endpoint (when I share via OneDrive):

https://graph.microsoft.com/v1.0/users/{user-id}/messages/{msg-id}/attachments

Returns the actual attachments on the email (i.e. images). I am able to extract a href off the body content but I do not know how to download the content that is linked? i.e.

https://sharepoint-my.sharepoint.com/:x:/g/personal/administrator/<id?>>?e=4%3a0uILKI&amp;at=9\

When I attach when a new email is created:

https://sharepoint.sharepoint.com/:w:/t/TestTree/<id?>

Again I don't know how to download the content that is being linked in the href.

Any idea how I can do this guys? Thanks

Outlook
Outlook
A family of Microsoft email and calendar products.
3,417 questions
Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
11,419 questions
OneDrive
OneDrive
A Microsoft file hosting and synchronization service.
974 questions
SharePoint
SharePoint
A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.
10,273 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Deleted

    This answer has been deleted due to a violation of our Code of Conduct. The answer was manually reported or identified through automated detection before action was taken. Please refer to our Code of Conduct for more information.


    Comments have been turned off. Learn more

  2. eggy mcegg 0 Reputation points
    2024-07-24T08:33:43.2+00:00
    0 comments No comments