How to count unread mail in uipath

To count unread mail in UiPath, you can use the Get Mailbox Items activity and then filter the results to only include unread emails. Here's an example of how you can do this:

  1. Add a Get Mailbox Items activity to your workflow and configure it to connect to your email account.
  2. In the Get Mailbox Items activity, set the Query property to Unread to retrieve only unread emails.
  3. Add a For Each activity to iterate through the retrieved email items.
  4. Inside the For Each activity, add a Get Item activity to retrieve the Unread property of each email item. This property will be True if the email is unread and False if it's read.
  5. Add a Counter activity to count the number of unread emails. You can use the Increment property to increment the counter for each unread email.

Here's some sample code to illustrate this:

// Get unread emails
Get Mailbox Items
    Query = "Unread"
    Mailbox = "your_email_address"
    Password = "your_email_password"

// Iterate through the retrieved emails
For Each item In Get Mailbox Items.Output
    // Check if the email is unread
    If Get Item(item, "Unread") Then
        // Increment the counter
        Counter.Increment
    End If
End For

// Display the count of unread emails
Message Box "Unread emails: " & Counter.Value

Note that you'll need to replace your_email_address and your_email_password with your actual email address and password.

Also, keep in mind that this is just an example and you may need to modify it to fit your specific requirements. For example, you may want to filter the emails by subject, sender, or date range, or you may want to count only emails from a specific folder.