Flow that Sends E-mails with Attachments from Shared
A SharePoint Flows tutorial by Peter Kalmström
flow can take data from a SharePoint list and add it to
an outgoing e-mail, something that is useful when sending
from a shared mailbox.
In some cases, it is better to let users add e-mail data
to a SharePoint list instead of sending the information
directly from a shared mailbox. You will have a better control
of what is sent. and the information in the SharePoint list
can be sorted, filtered, searched and displayed in different
views. Furthermore, you don't have to give a lot of people
access to the shared mailbox. They only need permission
to create items in the SharePoint list.
E-mails with attachments
In the demo below Peter Kalmström, CEO and Systems Designer
of kalmstrom.com Business Solutions, shows how to create
a flow that picks information from a SharePoint list and
adds it to an e-mail that is sent from a shared mailbox.
Peter even shows how to include attachments in the flow
generated e-mails. This is of course important when the
e-mails are sent to people who cannot share files in a SharePoint
library, for example to customers or suppliers outside the
Including attachments in the flow generated e-mails is however
a bit complicated. In his research on how to best get the
flow to allow attachments, Peter found inspiration in a
blog post by
Django Lohn. The flow can of course be used without
the attachments part, and then it is much easier to create.
The SharePoint list
Before Peter starts with the flow, he creates a SharePoint
list for the e-mail data with columns for receiver, subject,
attachments and body.
Create a flow that picks data in new list items and
sends e-mails from a shared mailbox
Use the shared mailbox account when you create the flow.
Peter gives each flow step a suitable name to make it easier
for colleagues to follow and change the flow if needed.
Start creating the flow from inside the list or
by going to https://flow.microsoft.com.
Use the trigger 'SharePoint - when an item is created'.
Select or write in the list for e-mail sending you
created and the site where it is situated.
Add an action to contain the attachments: 'Variable:
initialize variable'. Give it a name and select the
Add an action to get the attachments from the list
item: 'SharePoint - Get attachments'. Select the same
site and list as in point 2 and the dynamic content
Add a loop through the attachments by selecting
'Add an apply to each'. Use the dynamic content 'Body'
Add an action that gets the content from the attachments:
SharePoint - Get attachment content'. Select the same
parameters as in step 4 plus the dynamic File identifier
Add the attachment content action to the array using
'Variable - Append to array variable'. Enter the name
'Attachments' and build a JSON object for the value:
Outside the loop, add an action: 'Office 365 Outlook
- send an e-mail' and add the dynamic content for the
fields To, Subject and Body. Under advanced options,
specify HTML and set the importance to Normal. At Attachments,
add the dynamic content variable 'Attachments'.