Showing results for 
Search instead for 
Did you mean: 
Helper I
Helper I

Dynamics 365 - Use flow to take an attachment from an email on an opportunity and place it in the specified Sharepoint Location for the Opportunity?

I am trying to trigger a flow when an email record is created.  I use a condition that it is regarding an opportunity.

Then I want to get the attachment from the email and put it in the Opportunity's Sharepoint file location.


1. I have seen solutions stating "get attachment" but I do not see this flow option with Dynamics 365.  Can I use the "attachment" entity?

2. How do I find the Sharepoint location regarding the opportunity?


Thanks in advance community.

Community Support
Community Support

Hi @colbournescott,


1. You can get the attachments from the email, then store them into the attachment entity, then you can create the association between the opportunity entity and attachment entity.

2. Or you can store attachments into the SharePoint list, then create the association between the opportunity entity and SharePoint list.

Best Regards,
Community Support Team _ Lin Tu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Solution Sage
Solution Sage

Hi @colbournescott 


1. Use the CDS connector to get the Attachment record associated with the email. You can find this by querying the activitymimeattachments entity where the objectid is equal to the guid of the Email record. Then use the base64ToBinary function in Flow to convert the body property of the attachment record, the output of which you can use in step 2 below.

2. The SharePoint location for each record should be available by querying the Document Location (sharepointdocumentlocations) entity where the regardingobjectid is the guid of the Opportunity record. Once you have the Document Location associated with the Opportunity record you can use the SharePoint connector to create the file in SharePoint, using the Relative URL field from the Document Location. The filecontent property in the Create File in SharePoint action should be set to the value you generated in step 1 above using the base64ToBinary function.


The file should then be visible in the Documents tab of the Opportunity within Dynamics 365 and safely stored in SharePoint. One thing to look out for when querying the Document Locations is that they won't exist if the Documents tab has never been viewed on the record in Dynamics. If this is the case you just need to add some additional steps to create this. I have used this article to achieve something similar using Note attachments (

Hope that helps point you in the right direction.

Did I answer your question? Mark my post as a solution!

Proud to be a Flownaut!

Follow me on Twitter at @QG_LeeJHarris

Or on LinkedIn at in/leejharris

Hi @LeeHarris 


Came across this today when looking for a solution to this issue.  Your solution worked for me.  Thanks a lot!

Kudo Kingpin
Kudo Kingpin

I also found a blog post about "Move Attachments from Tracked Email to SharePoint using Microsoft Flow". Even though the blog post was written before CDS connector is available, it should work with CDS connector too.

Helpful resources

UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Top Solution Authors
Top Kudoed Authors
Users online (1,244)