Email with attachment from outlook 365 to sharepoint online

D'Accardi Ugo (Services Italy) 1 Reputation point
2022-01-27T15:03:23.197+00:00

hi
it's possible to upload an email from outlook office 365 with all his attachments, in SharePoint?
Thanks
Ugo

Microsoft 365 and Office | SharePoint | Development
{count} votes

2 answers

Sort by: Most helpful
  1. D'Accardi Ugo (Services Italy) 1 Reputation point
    2022-01-27T16:04:48.54+00:00

    I want to do this for selected email messages.

    0 comments No comments

  2. Rob Windsor 2,001 Reputation points
    2022-01-27T19:42:29.747+00:00

    If you are planning to write code, I suggest that you use the Microsoft Graph. You can do this in most types of C# applications or using the SharePoint Framework.

    To get the information about the email message you'll want to take a look at the operations in the Mail endpoint, specifically Get Message, List Attachments and Get Attachment. To save the email message and attachments to a SharePoint document library, you'll want to look at the operations in the Files endpoint, specifically Get Drive, Create Folder and Upload.

    The basic steps would be:

    1. Find the Id of the email message.
    2. Create a folder in the target SharePoint document library. Use the Id of the mail message as the name of the folder.
    3. Get the body of the email message using the $value path segment and upload it to the folder in the document library created in Step 2.
    4. Iterate through the attachments for the email message, getting the file content for each using the $value path segment, and uploading each to the folder in the document library created in Step 2.

    You could also use Power Automate. The process is basically the same as described above but the mechanics are different. There are several blog posts and YouTube videos that describe this process in detail, here's one example: How to Save email attachments to SharePoint with PowerAutomate.

    I hope this helps.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.