Power Automate: How to Send an email with options from a Shared Mailbox

With the Send email with options action in Power Automate, you can send an email to a user with a respond option and wait for completion.
Unfortunately, this email cannot be sent from a shared mailbox by default.

There are several user voices out there and some of them are actually ‘Under Review’ but until Microsoft has incorporated this into the action, I will explain how you can send the email with options from a shared mailbox.

The set up

The solution consists of sending out the mail with options like you usually do and re-sending the email from a shared mailbox.

So for this to work, you need to configure two flows:

  1. The flow that sends out the initial mail with options from the flow owner (or the one who’s connection is used)
  2. The flow that re-sends the mail with options from the shared mailbox

Sending out the initial mail with options

This is basically the same mail with options you configure normally, except for the following changes:

  • The email needs to be sent to the shared mailbox that eventually will send the mail with options to the final recipient

(Shared Mailbox is just the name of my test shared mailbox in this case)

  • The subject needs to be altered to that the second flow knows which mail needs to be resent and where to send the email to. More on this below

Altering the subject

For the second flow to know which mail needs to be sent and where to send the mail to, an alteration needs to be made to the subject of the initial mail with options:

  1. Assigning an unique identifier to the subject of the mail so that you can filter out the email from any other mail that arrives in the shared mailbox
  2. Including the Recipient and (if applicable) the Carbon Copy (CC)/Blind Carbon Copy (BCC)
  3. Including the actual subject

I put all of these alteration properties into string variables so that I can access them easily.

Assigning an unique identifier

This is something you can think of yourself, as long as you’re certain that this unique identifier is not used inside any other emails that will arrive at the shared mailbox. I used SHAREDMAILBOXMAILWITHOPTIONS for this:

Including the Recipient and CC/BCC

In this example I only use To and CC recipients.
These variables contain the actual recipient and the actual CC:

(I only have one user in my tenant, so that’s why I use the same email address several times. You can also use dynamic content ofcourse!)

Including the actual subject

The same method applies for the subject, just initialize another variable that includes the actual subject:

Putting it all together

Now it’s time to put all of this information together and make sure to separate the various properties from each other. I used another variable for this:

These are all of the properties we configured earlier, separated using double pipe symbols (||). You can choose whatever separator you want to use, as long you’re certain it’s unique for separating (e.g. a semicolon isn’t unique because that’s used also for separating recipients in the To and/or CC variables).

You also need to assign identifiers to your properties so you can filter them out in your second flow. I used the following identifiers:

  • To: for the recipient
  • CC: for the CC
  • Subject: for the subject

Make sure there is a separator in there as well (different from the other separator ), because we need to split the identifiers from the action values as well later on. As you can see, I used a colon (:) for this.

Finalizing the send mail with options action

Not that our altered subject is fully configured, we can proceed by completing our Send mail with options action. As said, it’s basically the same configuration as you would normally do, except the recipient and the subject are different:

Sending the mail with options, results in receiving the following email:

As you can see, the mail with options is sent from a personal account (mine in this case), to the shared mailbox and with the altered subject.

Re-sending the mail with options from the Shared Mailbox

Now that we have completed the initial mail with options and sent it to the shared mailbox, we now need to make sure the email is being resend to the correct recipient(s), with the correct subject. We do that using a second flow.

Identifying the mail with options from the shared mailbox

The trigger for this second flow is the When a new email arrives in a shared mailbox (V2) trigger. Within this trigger you need to configure the following attributes:

  • Which shared mailbox to look in. In my case this is the Shared Mailbox mailbox
  • In which folder to look for the email. If you use a Rule to move the mail with options to a specific folder on arrival, you need to select that folder. In my case, I don’t use a Rule for this so the email arrives in the Inbox folder and I did’t need to change that
  • Which subject to filter on. In this case we used SHAREDMAILBOXMAILWITHOPTIONS as an unique identifier so that will be our subject filter.
    Please note: you cannot use AND/OR statements within this filter option. You can only filter on one attribute

Filter out the recipient(s) and subject

Now that we have identified our mail with options, we need to filter out the To, CC and Subject attributes from the subject. To do this, we must do the following:

  1. Separate all of the attributes into an array
  2. Filter the array on the specific attributes
  3. Split the prefixes (To:, CC: and Subject:) from the actual values that we want to use
Separating the attributes

For this, we can use the initialize variable option to initialize a new array variable. The Value of this variable is the subject of the email, split by the separator we configured in our first flow (which are the double pipes: ||):

split(
	triggerBody()?['subject'],
	'||'
)

When running the flow, you will see that the outcome of the action will separate each attribute:

Filter out the attributes

Now that we have our array filled with all attributes, it’s time to filter this array to get all of the attributes. I use a parallel branch for this so that all attributes are filtered out simultaneously and added the Filter array action to each of the parallel branch.

The array we want to filter is our arrFullSubject variable we just initialized. We want to filter out the row that contains To: for our recipient, the row that contains CC: for our CC and the row that contains Subject: for our subject. Each row of our variable (except for the first row that contains the unique identifier), starts with on of these values so we can use the startsWith() expression. The startsWith() expression expects two attributes:

  1. The item that we need to check, which is the item() attribute in your expression builder
  2. The value we are checking for, which is the To:, CC: or Subject: string

This results into the following expressions:

To:

startsWith(
	item(),
	'To:'
)

CC:

startsWith(
	item(),
	'CC:'
)

Subject:

startsWith(
	item(),
	'Subject:'
)

This expression needs to be true to get a positive match:

Split the prefix from the actual value

Now that we have filtered our array into the separate attributes we are looking for, we need to make sure to only get the actual values and not the To:, CC: and Subject: prefixes.

First I initialized three more variables at the start of the flow that will store the values eventually:

  • varTo
  • varCC
  • varSubject

To do that, we must use the split() expression to split the array into the actual value and prefix, using the colon (:) separator. Because the actual value is the last attribute of our split array, we need to use the last() expression to get this value:

last(
	split(
		<ARRAY>;,
		':'
	)
)

Since we are still using using an array (filtering out an array results into a filtered array, because you can still have multiple items after filtering) and splitting only works on a string, we need to fetch the first item inside our filtered array (because we only have one item inside the filtered array) and perform our split() action on that value. The entire expression for the recipient value will look like this:

last(
	split(
		first(
			body('Filter_array_to_get_recipient')
		),
		':'
	)
)

You need to alter the expression three times to make sure the values from the recipient, CC and subject are being used:

Re-sending the mail with options from the Shared Mailbox

Now that we have all of our values stored into variables, we can proceed by sending the mail with options from our shared mailbox by simply adding a Send an email from a shared mailbox (V2) action and assigning the following attributes:

  • Mailbox Address: the shared mailbox you want to send the mail with options from (in my case, this is the Shared Mailbox mailbox)
  • To: our varTo variable
  • CC: our varCC variable
  • Subject: our varSubject variable
  • Body: the body from the email we identified using the trigger. You can use the Dynamic Content attribute Body for this.
    Make sure you enable the HTML view of your body, otherwise your body may fail to render correctly 
  • Importance: the importance of the email we identified using the trigger. You can use the Dynamic Content attribute Importance for this

Deleting the initial mail with options

Now that the mail with options is sent to the correct recipient(s) with the correct subject, we can now delete the initial mail with options from our shared mailbox. You can do this by adding the Delete email (V2) action and setting the Message Id property of the action to the Message Id of the email we identified using the trigger. You can use the Dynamic Content attribute Message Id for this.

With this in place, our second flow is complete and will now take care of sending your mail with options from a shared mailbox:

As you can see, the mail with options is now sent from the shared mailbox, to the correct recipient(s) and with the correct subject.

One final note: make sure that the account that is used for the following triggers and actions has access to the shared mailbox:

  • When a new email arrives in a shared mailbox (V2)
  • Send an email from a shared mailbox (V2)
  • Delete email (V2)

6 Replies to “Power Automate: How to Send an email with options from a Shared Mailbox”

  1. Good day. I am fairly new to Power Automate and I am trying to set up an email approval via shared mailbox as described. However, I do not see “When a new email arrives in a shared mailbox (V2)” as a trigger. Has this changed with newest version? Is there another trigger that I can use to send approval emails in Flow FROM a shared mailbox?

  2. Good day Rik
    I have created the flow however, it “times out” after the email is sent to the shared inbox. It does not forward/delete the email. I have had my IT department look (they are as much in the dark as I am). I was wondering if there is any way I could share my flow with you to take a look? Super frustrating after creating the flow, deleting it and starting over and over for a couple weeks.
    Thanks

Leave a Reply

Your email address will not be published. Required fields are marked *