cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Anonymous
Not applicable

Get SharePoint Document ID from Word email attachment

I am trying to automate the "Publish a major version" of documents stored in a SharePoint document library whenever one of those documents is emailed outside of our organisation - or received back into our organisation.

 

Ultimately what I want to happen is to provide our users with the ability to cc: a shared mailbox when they send (or receive) one of these Word documents, and Microsoft Flow will take the document, find the original document in the library, upload it as a new version of that file, and then "publish a major version" of the document - with the check-in comments set to the content of the email that was exchanged.

 

This all seems eminently possible except that I cannot figure out how to get the Document ID property out of the attachment in the email - I can extract the attachment itself, but getting the Word document properties seems impossible - and maybe it is, but it shouldn't be.

 

Does anybody have any suggestions to extract this number in a usable format within Microsoft Flow?

 

Each of these documents has a unique document ID assigned by SharePoint, which is stored in the Document Properties in Microsoft Word like this:

O-1234-5678

 

Where:

"O-" is just an arbitrary reference

"1234" is a reference to the document library in which the document is stored

"5678" is the ID of the document within that document library.

 

Since we are only (for the most part) dealing with a single document library, the only thing that matters is the "5678" that is relatively easily extractable from the Word document properties - if they were available to be extracted once the email attachment was pulled out from the email.

1 ACCEPTED SOLUTION

Accepted Solutions
Anonymous
Not applicable

Re: Get SharePoint Document ID from Word email attachment

I have figured my own solution this problem:

  1. Create a completely separate site collection from the main site, and enable Document IDs (allow >1hr for Document IDs to take effect).
  2. Create a temporary document library in which to store the files, verify that Document ID appears as a column (add it to the default view).
  3. Turn OFF the "Assign Document IDs" setting on the site collection (this will stop the site overwriting the Document ID on the documents stored in the library, and is why we need a completely separate site collection - it can't be done on the original site collection as it's a collection-wide setting).
  4. Use the SharePoint "Create File" action to store the files in that document library, followed by a "Get File Properties" action to retrieve the Document ID from the file in its temporary location.  This will be the original Document ID, since it wasn't overwritten by the new site collection.

This works a treat.

View solution in original post

3 REPLIES 3
Community Support
Community Support

Re: Get SharePoint Document ID from Word email attachment

Hi @Anonymous ,

 

Is there a file in the sharepoint library that is the same as the attachment of the email?

 

If yes, you could refer to screenshot below to create the flow:

1.PNG2.PNG3.PNG

 

The condition is to compare the “file name with extension” from the Get files action with “Attachment Name” from the trigger.

 

And the flow would run successfully to get the ID as below:

4.PNG

 

Best regards,

Mabel

 

Community Support Team _ Mabel Mao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

Re: Get SharePoint Document ID from Word email attachment

Thanks for your suggestions - I think I follow your logic - but unless I'm wrong it assumes that:

 

  1. The filename is unique across the library - we have > 10,000 files in this library, nested several levels deep, inside multiple folders + document sets.  There will inevitably be filename clashes.
  2. The filename stays the same - one of the issues I have is people taking documents out of SharePoint onto local hard drives, saving them locally, renaming them, then sending them externally.  When this happens, the filename will change but the document ID would be preserved (unless it is uploaded into another SharePoint site where it is overridden).  Likewise, when the external parties send the documents back, they are likely to rename them - so they will no longer be found in the library.  I am explicitly trying to overcome this issue, so being able to ignore the filename and rely on the Document ID - which is for this express purpose of finding a document irrespective of the filename / path - should be available to a Flow.

In the absence of any other solution at the moment I might try it out and see if it works (for me at least, who doesn't change the filename) - but as a complete solution to what I'm trying to achieve, it won't work across everyone else.

Anonymous
Not applicable

Re: Get SharePoint Document ID from Word email attachment

I have figured my own solution this problem:

  1. Create a completely separate site collection from the main site, and enable Document IDs (allow >1hr for Document IDs to take effect).
  2. Create a temporary document library in which to store the files, verify that Document ID appears as a column (add it to the default view).
  3. Turn OFF the "Assign Document IDs" setting on the site collection (this will stop the site overwriting the Document ID on the documents stored in the library, and is why we need a completely separate site collection - it can't be done on the original site collection as it's a collection-wide setting).
  4. Use the SharePoint "Create File" action to store the files in that document library, followed by a "Get File Properties" action to retrieve the Document ID from the file in its temporary location.  This will be the original Document ID, since it wasn't overwritten by the new site collection.

This works a treat.

View solution in original post

Helpful resources

Announcements
firstImage

New Ranks and Rank Icons released on April 21!

The time has come: We are finally able to share more details on the brand-new ranks coming to the Power Automate Community!

firstImage

Now Live: Power Virtual Agents Community!

We are excited to announce the launch of Power Virtual Agents Community. Check it out now!

firstImage

New & Improved Power Automate Community Cookbook

We've updated and improved the layout and uploading format of the Power Automate Cookbook!

thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Community Summit North America

The top training and networking event across the globe for Microsoft Business Applications

Top Solution Authors
Users online (7,562)