This is an example of automation that can be built in StudioWeb.
Context
The automation is created by the user who works in the Customer Service department. He is responsible for contact with users, partners and potential clients. One of the tasks is to check email messages and answer them. The user works partially remotely from home. This requires him to use a couple of devices to read emails. Mostly it is a desktop PC when working from the office, a laptop when working at home, sometimes a smartphone when travelling. Like many people these days the user is constantly spammed by unwanted emails that come from companies trying to sell different services. He is tired of setting up filters for every Outlook 365 on his devices to get rid of those messages. The process he would like to create will check every new email message and if the sender is one of those that he has on his list as “unwanted”, will be removed to keep the mailbox empty of spam.
Steps
01 - Create the Outlook Connection
Using the Integration Service connect your Outlook 365 account with the UiPath Cloud. This can be achieved in two ways.
- By configuring the connection in the Integration Service section in the UiPath Cloud.
- At the Studio Web design level when placing the first activity that works with Outlook 365.
02 - New process
Now by going to the Studio Web section we can start creating a new process.
- Provide a nice and intuitive name for it.
- Give it a short description that will explain what it does.
03 - Input data
We need to start by creating an argument and a value.
- The argument will handle the trigger-provided ID that corresponds to every new email message. It needs to be of an input direction, a text type and it should be named as “UiPathEventObjectId” (according to the DOCS).
- The value will contain all the unwanted email senders addresses and it can be always extended. It needs to be of a string array type where every single address can be added.
04 - Get Email
Now it’s time to work on emails.
- Using the Get Email by Id activity configure the Outlook 365 connection if this wasn’t be done earlier in the Integration Service.
- As the Email ID let’s provide the input argument created in the previous step.
05 - Loop through addresses array
To check new email messages and if they are sent by unwanted senders we need to go through every one of them and compare them with a sender property of our emails.
- Use the For Each activity. As a value, we need to use the one that we created in step 03.
- Let’s call the output item “SpamAddress”.
06 - Spam check
Now we need to compare if every item from the loop is the one that our email message was sent from.
- Let’s place the If activity inside the loop body.
- Using the Condition Builder select the Activity Outputs and choose the “From.Address” result of the Get Email by Id activity.
- From the dropdown list select the “equals” operator.
- In the last box use the “SpamAddress” item defined in the previous step.
07 - Removing spam
Now is the time for the last activity in the process. We need to remove messages where a sender email address is one of those we defined in the “UnwantedMailAddresses” array.
- In the “then” section of our if put the Delete Email activity. As the Outlook 365 connection is already in place we don’t need to set this again. It should propagate automatically.
- For the Email object let’s use the “Result” of an output of the Get Email by Id activity.
08 - Process publishing
Now we need to publish the process using the last button on Studio’s menu panel.
- You can leave all details as they are and just confirm it.
09 - Trigger setup
This is the last piece of the puzzle. Now we need to go to the Integration Service section in the Cloud portal.
- Go to the last tab called “Triggers”.
- Add a new trigger using the blue button on the upper right corner.
- As the connection search for Microsoft Outlook 365 (not the legacy one).
- Connection should be propagated automatically based on our connection that is already in place.
- Set the “New Record Created” as the event type.
- As a record select the message.
- On the right side select the process that was published in the previous step.
Feedback
Please let us know what do you think about this automation. Would you like to get more? Please let us know!