How to filter mails in outlook using uipath
To filter emails in Outlook using UiPath, you can use the Outlook
activity and the Search
method. Here's a step-by-step guide:
Prerequisites:
- You have UiPath Studio installed and configured.
- You have an Outlook account set up on your machine.
- You have the
Outlook
activity installed in your UiPath project.
Step 1: Create a new UiPath project
Open UiPath Studio and create a new project.
Step 2: Add the Outlook activity
In the Project panel, right-click and select "Add Activity" > "Outlook". This will add the Outlook
activity to your project.
Step 3: Configure the Outlook activity
In the Outlook
activity, configure the following settings:
- Application: Select the Outlook application you want to use.
- Profile: Select the Outlook profile you want to use.
- Folder: Select the folder you want to search in (e.g., Inbox, Sent Items, etc.).
Step 4: Use the Search method
In the Outlook
activity, click on the "Search" method and configure the following settings:
- Search criteria: Enter the search criteria you want to use to filter emails (e.g., subject, sender, recipient, etc.).
- Search scope: Select the scope of the search (e.g., current folder, all folders, etc.).
Step 5: Filter emails
In the Search
method, you can use various filters to narrow down the search results. For example:
- Subject:
Contains "specific subject"
- Sender:
Is "specific sender"
- Recipient:
Is "specific recipient"
- Date:
Is greater than "specific date"
You can combine multiple filters using logical operators (e.g., AND, OR).
Step 6: Iterate through the search results
Once you've configured the search criteria and filters, you can iterate through the search results using a For Each
loop.
- Variable: Create a variable to store the search results (e.g.,
email
). - Collection: Set the collection to the search results (e.g.,
Outlook.SearchResults
). - Loop: Use a
For Each
loop to iterate through the search results.
Step 7: Process each email
Inside the For Each
loop, you can process each email using various activities, such as:
- Read email: Use the
Read Email
activity to read the email content. - Delete email: Use the
Delete Email
activity to delete the email. - Move email: Use the
Move Email
activity to move the email to a different folder.
Here's an example code snippet:
<Activities>
<Outlook>
<Search>
<SearchCriteria>Subject Contains "specific subject"</SearchCriteria>
<SearchScope>Current Folder</SearchScope>
</Search>
<ForEach>
<Variable>email</Variable>
<Collection>Outlook.SearchResults</Collection>
<Loop>
<Read Email>
<Email>$(email)</Email>
</Read Email>
<!-- Process email content here -->
</Loop>
</ForEach>
</Outlook>
</Activities>
Note: This is just a basic example to get you started. You can customize the search criteria, filters, and processing activities to fit your specific requirements.