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.
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)
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:’))
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).
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.
Is it possible to take the new body of the email and add it to a comments field?
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.
Hi Steve,
Thanks I will give it a go.
Cheers
John.
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.
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.
Does it work with replies to the emails if someone replies to it?
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.
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.
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.
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)?
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’
Hi thank you for this, I have searched a full day for an instructional to do what to need (send automatic email to external email in a SharePoint list). I need to do the first flow of in your described process, however it needs to be conditional to only if a value in another column on that list equals a certain value. To clarify, I have a SharePoint list that creates a new line item using a flow I created to record answers to an MS Form sent to external candidates. Their answers populate into corresponding columns in the list, which records their email address. The objective is to screen applicants, so dependant on a Yes/ No answer to certain questions I want the email to automatically send to the respondent (candidate) email I.E. if value in column D equals No, then send email to email address in Column B.
Hi Hanna, you can add a “Trigger Condition” to a Flow, so that it only runs if a column contains a specific value. Here are some details on how to add a Trigger Condition https://powerusers.microsoft.com/t5/Power-Automate-Community-Blog/Power-Automate-Trigger-Conditions-made-EASY/ba-p/441348