Microsoft Flow, linking email to SharePoint List items


Using SharePoint and Microsoft Flow, I built a system for sending emails to external people and then processing the replies, including extracting attachments and linking back to the original SharePoint List Item.

Here’s the process:

  • User creates a new List Item with the email address of an external person (can be internal also)
  • Using Flow, send an email to the external person’s email address:
    • Subject line includes a reference number (the list ID value for the new list item)
    • Body text including a link to a document the user can download, print and sign (think contract document)
    • Instructions to reply to the same email with the signed document attached
  • A second Flow, monitors the Outlook mailbox (for the user that published the Flow)
    • Extracts attachments
    • Reads the subject line and using a string function to extract the ID value
    • Get the item in the source SharePoint list using the ID to find the source item
    •  Email the approving manager (entered into the SharePoint list item) with a link to the downloaded attachments

The First Flow, runs when a new list item is created in SharePoint. I do one little trick with the Contractor Email Address so the Flow will send to email addresses outside the organisation.

Flow-Send-Email

The second Flow, is based on the Flow template for extracting attachments from an inbound email.

The HTTP request creates a folder in the SharePoint Document library and later I save the attachments into the folder. This makes it easy to send a link to all attachments (hint: just send a link to the folder created in this step)

InkedFlow-Create-Folder-Extract-Attachments_LI

This part of the second Flow, reads the subject line and extracts the ID which I included in the first Flow’s email subject line.

First you need to extract the reference from the inbound emails subject line using this function:       last(split(triggerBody()?[‘Subject’],’Ref:’))

StringFunc.PNG

Now convert the Reference number from a String to an Integer and then use it to lookup the item in the source list with the same ID (see Get Item below).

InkedFlow-Send-Email-WithRef_LI

That’s it! So as a quick recap, the user initiates the process by creating an item in a SharePoint List. Flow sends an external email. The recipient adds attachments and replies to the source email. Flow extracts attachments, reads the subject line and pulls out the ID of the source list item. Using Get Item, Flow then reads data from the source list item that initiated the process.

11 thoughts on “Microsoft Flow, linking email to SharePoint List items

    1. Hi John, yes the message body can be accessed from Power Automate. It is stored in the ‘Body’ value. You can convert HTML to Text also using Compose and Substring functions.

  1. Hi Steve,

    This is what I am trying to do.
    1. Check Shared Mailbox for emails that will Issue xx in the subject
    2. Check to see who the email is from, is it from the creator of the list, assigned to person of the list or the Sub-Contractor Assigned To.
    3. Depending who it was from copy the email body to one of two comments fields.

    I think I need to check for the ID first then check to see who the email is from.

    Once I have that then add to the relevant comments field.

    Does that sound about right?

    John.

    1. Hi John, that sounds like the right approach. The encoded “Ref:ID” into the subject line, so I can easily find the ID and also use this to confirm it is an email I want to process.

    1. Yes, but make sure the references is at the end of the subject line to make it easy to extract. The Flow triggers when an email arrives in the Inbox and doesn’t distinglish between new emails and replies.

      1. Hi Steve,

        It fails if I put text after the ID number i.e. instead of “Ref:1” I have “Ref:1 Burst Pipe”

        John.

      2. Hi John, that is due to the Set Variable using the “Last” function. That returns everything in the subject line after the string “Ref:” and then converts it to a number. This will fail if it has a character that isn’t a number.

  2. Is it possible for sharepoint list to send out reminder emails (based on column values) and also a week prior to date due (based on column values)?

    1. This can be done using PowerAutomate. The built in Reminder Flow can work on any date column. The same Flow can be modified to check a column value if you have more complex requirements e.g. send a reminder if the item status column is no ‘completed’

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s