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)

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

  1. Hi, When adding the delete email step, as soon as the email is deleted, the flow thinks a response has been made to the email. Is there a way around this?

    0
    0
    1. As far as I know, a delete action won’t trigger the response of the mail with options. I’ve tried it myself, but I don’t get this result. Are you sure you didn’t respond in any other way?

      0
      0
  2. I’ve got exactly the same setup as the example provided and it’s saying the provided value is Null. Frustrating!!

    0
    0
  3. Hi Rik,

    This article was very useful for me. Thank you so much. By the way I have a query regarding how can we add a comment box to this send email with options. Is there any possibility?

    0
    0
    1. Unfortunately, it is not possible to add a comment box to a mail with options. If you want to use comments, you should use an approval action or an actionable message (using adaptive cards)

      0
      0
  4. Getting the below error in the second workflow –

    InvalidTemplate. Unable to process template language expressions in action ‘Set_variable_varTo’ inputs at line ‘0’ and column ‘0’: ‘The template language function ‘split’ expects its first parameter to be of type string. The provided value is of type ‘Null’. Please see https://aka.ms/logicexpressions#split for usage details.’.

    Expression i have entered in the Set Variable

    last(
    split(
    first(
    body(‘Filter_array_to_get_recipients’)
    ),
    ‘:’
    )
    )

    0
    0
    1. It seems like the outcome of your previous Compose action (Filter array to get recipients) is empty. Are you sure you’re using the correct expression in that action and that the arrFullSubject array variable is filled with the correct information?

      0
      0
    2. Thanks for all the comments. I have a problem in the 2nd workflow for the intialize variable arrfull subject. I received the email to my shairedmail box with the subject. but keeps telling me that it is null and breaks.

      Can you please help me in this?

      0
      0
  5. Hi Rik,

    You mentioned that “the first flow still waits for the response for that email. Whether it’s forwarded or not. The second flow is only used for forwarding the email. The first flow is used for handling the outcome.”

    Am I correct to assume that whatever decision is selected by recipients of 2nd flow will be the outcome that we can extract in 1st flow to move with further steps in our 1st flow.

    0
    0
  6. Hi Rik,

    Hope you’re well!

    I’m sending you with regards your article: https://www.about365.nl/2020/03/29/power-automate-how-to-send-an-email-with-options-from-a-shared-mailbox/

    First of all, Thank you so much for your effort and time to make this article.

    I have a question, I’ve went through all the steps and it’s working fine. except that in the first flow I have the variable varTo taken from sharepoint list for a column contains the email addresses which I’m not able to do in the second flow because it’s not connected to a sharepoint. I’m a new user of power automate and I don’t know what step do I need to make so I can connect the initialize variable: varTo to the same column of email addresses in the sharepoint.

    Awaiting your response and thanks in advance

    0
    0
    1. Your first flow should provide the contents of your varTo variable to the shared mailbox and from there, the second flow should pick these values up again from the subject. Every bit of information regarding recipients and subject is stored into the subject of the mail to the first flow (to the shared mailbox). The second flow will use several expressions to fill the variables again so make sure the correct recipients receive the mail with options

      0
      0
  7. Once the email is forwarded from the shared mailbox to the respective recipients and they respond to the options provided, how to track these responses?

    Because the second flow now comes from the shared mailbox with doesn’t have the sharepoint Dynamic items for the reponses to be taken into account.

    0
    0
    1. That shouldn’t matter. Because you forwarded the Mail with Options, the first flow still waits for the response for that email. Whether it’s forwarded or not. The second flow is only used for forwarding the email. The first flow is used for handling the outcome

      0
      0
  8. Hi- I am having a problem with the second flow. I must’ve done something wrong but when I try to set variable varTo and varSubject I get an error saying that variable has not been initialized. I have done all the steps listed on the blog. I must be missing something. Any help you can provide?

    0
    0
    1. Well, basically the error tells you what’s wrong 😉. You probably didn’t initialize the variables at the beginning of your flow as stated in the ‘Split the prefix from the actual value’ paragraph

      0
      0
  9. HI Rik! I just steped with this post when looking for answer to a matter that I can´t solve.

    I need to send an email with options from a shared mailbox to aproximately 40 people in the company, then, I need to collect all the answers and register them in an SP list. It is not an approval flow, just an availability test, so the users will have only one option.

    Do you think that this flow can help me to cover this? I am a basic user and for sure I will have some issues trying to setting up this flow, but I would like to be sure that this is the solution that I am looking for before I try it (for sure it will bring me some headache if it is not what I need)

    Hope you an read this!
    Thank you!

    0
    0
    1. Yes you can use this for that scenario. Please note that your Subject will be huge if you’re adding 40 recipients. I don’t know for sure if that’s accepted. Otherwise you may want to store the recipients in the body of your email and split that to use it for multiple recipients

      1
      0
    2. Hi Rik! thank you for your reply.

      I agree with you regarding the subject, so I am trying to collect emails from a SP list but the flow runs timed out every time. I will need to use my creativity here! thanks for your help.

      0
      0
  10. I have been able to implement this solution and I receive the emails in the shared and forwarded email however, when I select the button on the forwarded email, it is not updating SharePoint. If I open the email in the shared mailbox and select the button, it DOES update SharePoint. Why would it work in the original email but not in the forwarded email? I looked at the URL for both, and they are exactly the same. Thoughts??

    0
    0
    1. The answers are being gathered from your first flow as you normally would process the Mail with options. The second flow is only used for resending the email from a shared mailbox

      0
      0
  11. Hi Rik,

    I have some questions,
    Can we use the email address from SP list with difference information in the email body?

    0
    0
    1. Sure, you can put whatever email address you want to use. I don’t know exactly what you mean by ‘different information in the email body’. You can alter the email body a bit, but that required some advanced replace() expressions as you still need the HTML for the respond buttons.

      0
      0
    2. I meant the email’s body will fetch from the SP list on each line depends on each users, can I have your email ? and I will tell you all my requirements and what I’ve done on my flow

      thank you in advance,

      0
      0
  12. Hi –

    It is getting stuck at “Send email with options” because it needs the approver to choose one of the options before it can go onto the next step.

    Does an option need to be chosen before it can go onto the next step? In my case, the Trigger when a new email arrives in a shared mailbox.

    Should this be two different/separate flows? Currently, I have it set as one flow with two triggers.

    1
    0
    1. The second mail (from the Shared Mailbox) is being sent from another flow (as stated in the ‘Re-sending the mail with options from the Shared Mailbox’ chapter) so it doesn’t have to wait for the Mail with options has completed. A mail with options is not assigned to a specific account. Anyone with the link can ‘approve’ it. That’s why you can use this solution.

      0
      0
  13. How are you getting the response from the approver in the second flow to utilize it further. It is no longer in dynamic content because it was created in the first flow. In my case I’m using “approve” or “reject” which will then be updated in CDS table.

    0
    0
  14. hi, thank you for your sharing. I’ve followed your step to setup but I got an error

    Correct to include a valid reference to ‘Filter_array_to_get_recipient’ for the input parameter(s) of action ‘Set_variable_varTo’.

    please help

    0
    0
    1. Are you sure you’re Filter action for the recipient is named Filter array to get recipient? I think there is a mismatch between the actual name and the name you’re calling on in your Set variable action

      0
      0
    2. Good evening Rik,

      I am having the same issue everybody is reporting here. the moment i try to set this function: last(split(first(body(‘Filter_array_to_get_recipient’)),’:’))

      I got this error message:
      Correct to include a valid reference to ‘Filter_array_to_get_recipient’ for the input parameter(s) of action ‘Set_variable_-_Subject’.

      can you help me, please?

      0
      0
    3. This error will be thrown if your reference is incorrect. So somewhere in the line there must be something configured incorrectly. Please recheck if all of your action names are configured and referenced correctly

      0
      0
  15. Thanks for sharing the way to solve me pain!
    I followed yours and got a good result until last week that i just noticed that the second one to trigger the email isn’t work out properly.
    Some emails are sometimes sent with no Subject: or no TO: and it doesn’t throw me the error as well 🙁
    Nowadays i use this practice to send out more than 40 emails a day.. do you think the number is matter in my case?

    Thank you sooo much!

    0
    0
    1. That’s weird. It shouldn’t be related to the number of emails I guess.. It should at least contain the identifier in the subject…
      Can’t you identify where this goes wrong using the Flow History? From which point does the subject variable become empty?

      0
      0
  16. Is there a way from which we can reply to the email stored SharePoint list and create a mail chain same as outlook?

    0
    0
    1. I’m guessing it’s technically possible, but I haven’t figured it out myself yet unfortunately. I think it’s a quite complex solution with multiple flows involved

      0
      0
  17. Hi Rik,

    Thanks for sharing the steps in such details. I followed your steps to configure the flow but it failed at the step when the flow is to separate the variables. The error prompted an invalid template stating that the first array has to be a string. Not sure what I did wrong there. I checked several times but noted I followed each step correctly. Appreciate if you could share if you know how I could resolve this. Thanks.

    0
    0
    1. Hi, in which step exactly does your flow fail? Based on what you describe, the input of your action seems to be empty, so you need to make sure that that value has been populated correctly. Please let me know where it fails and I can try to help you out

      0
      0
    1. Are you sure your email body is correctly configured? The mail with options body isn’t different from the send an email action as far as I’m aware of.
      If you’re using an HTML body, make sure your tags are closed correctly.

      0
      0
  18. Hi,

    I not not able to get the trigger, When a new email arrives in a shared mailbox to run as it keeps waiting for the response from step 1.

    0
    0
  19. 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

    0
    0
  20. 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?

    0
    0
    1. Found it. Thank you. Now I am just trying to work through the steps. Thanks again

      0
      0

Leave a Reply

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

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

The reCAPTCHA verification period has expired. Please reload the page.

This site uses Akismet to reduce spam. Learn how your comment data is processed.