How to read unread mails in outlook using uipath
To read unread emails in Outlook using UiPath, you can follow these steps:
Prerequisites:
- You have UiPath Studio installed on your machine.
- 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" > "Get Items from Folder".
Step 3: Configure the Get Items from Folder activity
In the "Get Items from Folder" activity, configure the following settings:
- Folder: Select the Inbox folder.
- Search Criteria: Set the "Search Criteria" to "Unread" to retrieve only unread emails.
- Search Scope: Set the "Search Scope" to "Current Folder" to search only in the Inbox folder.
Step 4: Add a Loop activity
Add a Loop activity to iterate through the retrieved emails.
Step 5: Add an Read Email activity
Inside the Loop activity, add an "Read Email" activity to read the contents of each email.
Step 6: Configure the Read Email activity
In the "Read Email" activity, configure the following settings:
- Email: Select the email from the previous step.
- Read: Set the "Read" property to "True" to mark the email as read.
Step 7: Run the workflow
Run the workflow to execute the activities.
Here's the sample code:
<Activities>
<GetItemsFromFolder x:TypeArguments="x:MailFolder" x:Name="GetUnreadEmails">
<Folder>x:Inbox</Folder>
<SearchCriteria>Unread</SearchCriteria>
<SearchScope>CurrentFolder</SearchScope>
</GetItemsFromFolder>
<Loop x:TypeArguments="x:MailItem" x:Name="LoopUnreadEmails">
<Items>
<GetItemsFromFolder.Item />
</Items>
<Body>
<ReadEmail x:TypeArguments="x:MailItem" x:Name="ReadEmail">
<Email><LoopUnreadEmails.Item /></Email>
<Read>true</Read>
</ReadEmail>
</Body>
</Loop>
</Activities>
This code retrieves unread emails from the Inbox folder, loops through each email, and marks each email as read.
Note: Make sure to adjust the code according to your specific requirements and Outlook configuration.