From the course: Microsoft Teams: Automating with Bots, Connectors, and Flows

Post a message in a team when an Outlook email arrives

From the course: Microsoft Teams: Automating with Bots, Connectors, and Flows

Start my 1-month free trial

Post a message in a team when an Outlook email arrives

- [Instructor] If you get emails that you then need to forward to your colleagues or other teammates, there's a different way you can approach this, and you can automate it. So instead of forwarding that email or copying the content of that email and pasting it as a message here in a channel, we're going to create a flow that can do that for you. Notice that we're in the Landon Hotel team right now. We are working in the Catering channel, and this is a brand-new channel. There are no conversations that have started here yet. We're going to automate and set something up that when something comes in with a specific subject or specific terms in the body of that message, that it knows to post it here as a new conversation. For this, we need to go to the Power Automate app. So let's go over here to the homepage that I have opened in a different tab. Let's go to the Office App Launcher, and let's select Power Automate. From the home page, we can search for templates that we're looking for. We're looking for a template that's going to help us with Outlook and with Teams. So we're going to type in those two terms and then press the Enter key. From the results that we get, we're looking specifically for a template that's going to take that message from the email and post it as a message within a specific team and channel based on certain criteria being true, and that's the one titled "Post message to Microsoft Teams when an email arrives in Office 365 Outlook." Let's select that template. The first thing that we need to do is make sure that all of the accounts are logged in that this flow will need to access in order for it to automatically perform the actions needed. And if we scroll down, there are two applications that it's going to need to work with: Microsoft Teams and Office 365 Outlook. I'm logged into both of those accounts with Jen's account, the green little checkmarks here indicating that each of these are a valid connection. If you see the blue plus sign there instead, you will need to select that to log in and validate your email address and password that's associated with your Microsoft 365 account. Let's go ahead and select Continue. The first thing that we need to do is we need to say what needs to happen when a new email arrives. So what action is going to be taken if it is triggered? So we're going to be looking in the inbox. That's what this folder says, but if we want to go to a different folder, we can select the Show Picker and then choose one of the folders from the Outlook mailbox. I'm going to go ahead and click outside of this so that it remains Inbox. You also have some advanced options that you can work with. Let's go ahead and select Show Advanced Options. This is if you want to add additional email addresses in the To: line. So maybe it's an email that was to more than just you. If it's someone that is on the CC line or the To: or the CC line, the From:, you can also indicate the importance level, if it has attachments, and then this one is one that's a bit of a gotcha, but you can include attachments with what you're posting in Teams. That is currently not working. So even if you were to select Yes for this, it is not going to include the attachment with the message that it posts in that channel conversation. All right, we're not going to set any of the advanced options, so I'm just going to select Hide Advanced Options, and we're going to move on from what's triggering this flow to the conditions that need to be met. So we're going to Expand Condition. We can have it look for information in the body, the subject, or other areas. The default is that the dynamic content that it's looking for is in the body field. I'm going to select the X to delete this. By selecting anywhere in this field, it's going to show me the other parameters that I can include. I'd like to include subject, so I'm going to select Subject, and then I'm going to move down. As we move down, notice the next field says contains. By selecting this field, you have a list of: contains, does not contain, is equal to, is not equal to. We're going to leave this set to contains because we have a specific subject title that it's looking for to be true to know if it should send this message as a message over to a Teams channel. So let's leave it set to contains, and then we're going to type in for the Choose a value a specific subject that needs to be in the email, and that is Landon Hotel Dining Options. All right. There we go. All right. Let's move on down. So if that condition is true, if it finds that title in the subject line, where should it post this message? We need to select the team, which is going to be Landon Hotel. There it is. And these are only the teams that you are an owner or a member of that you will see in that list. And then we need to specify one of the channels. So now this list is going to be all of the channels within Landon Hotel, and we're going to go with Catering. Okay. Now let's scroll down a bit more. All of these fields, notice the red asterisk, that's indicating that it's a required field. You will not be able to complete setting up this flow, nor will you be able to save this flow until you have all of those fields populated with information. In the message area, it's going to include a preview of all the contents that are in that email body. I'm going to close this Body Preview dynamic content. By clicking anywhere in the field, it gives me the additional parameters, and I'd like to include the complete body. So it's going to say Body. It also has a message down here, just letting the person know that's reading this within the team channel that this message content came from Office 365 Outlook email, because when it's posted, it's going to be posted with Jennifer's name, so it's going to look just like it was a manual post that she posted. There's not really another way for it to indicate that this came from Power Automate, that this came from a flow. All right. We are all set. Now, with this, let's move on down 'cause I would like to show you there's an if-no. So that was our if-yes. If this is true, if it finds that title in the subject and the other parameters that we have set, go ahead and post it. If it doesn't, what do you want it to do? So you could set up an action of what you want to happen if it's not true, or you can leave this empty and it's just treating it as, if it's not true, do nothing. And we're all set. We've set everything up. Let's go ahead and save this. Let's select flow checker to check and make sure we don't have any errors or warnings. We have zero for each. We're good. Let's close out of this. And we're going to test this. But since I ran the flow checker, let's save it one more time. Now, I have an email that Chung has already started composing that we're going to send through, so you can see what happens once it starts the process. Okay. So here's the email that Chung has been drafting to Jennifer. Notice that it has the subject that is needed in order for it to pick this up and to place it as a message within the channel. We have got some content here in the body, including a table. Let's go ahead and send that. Now, we're back to where we started over here in Power Automate. Let's go over here to Teams on the web, and here we are in the catering channel of the Landon Hotel team, and here's the email that has been automatically posted as a message within this channel. If we select See More, it will show us the complete message, where we can scroll to the left and right and up and down to read that message. Something to keep in mind, though, is if you're emailing a table like this, the formatting might not come out quite as intended. So be mindful of text formatting for any of those things that are going to be automatically posted. And that's how you can post a message in the team when an Outlook email arrives.

Contents