Showing results for 
Search instead for 
Did you mean: 

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!

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.

Hi Lee,

I do appreciate this is an old post but I am having the same problem however I do not have a lot of experience with flows so not sure how to design it.

Would you be able to help?


Thank you so much.

Hi @AsiaCz83 

Which part of the process are you having issues with? Can you share screenshots of what you have so far and where you are getting errors?

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

Follow me on Twitter at @QG_LeeJHarris

Or on LinkedIn at in/leejharris

Helpful resources

Power Automate News & Announcements

Power Automate News & Announcements

Keep up to date with current events and community announcements in the Power Automate community.

Power Automate Community Blog

Power Automate Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Users online (4,524)