Adding days an email has been in a pending category

Hello fellow UiPathers,

I need to create a bot that can pull emails from a mailbox that contain a “pending” category and adding a column showing how many days the email has been pending. The trouble is that an email is not pending the day it’s received, it could be categorized a week after. So in essence when the bot runs once per day and a new row gets added as pending, if the next day the bot runs again and the email is still pending then the days pending column should be a 1.

Any help would be lovely.

Thanks all.

Hi @srobey888

You can achieve this by using Build data table, Get outlook mail message

  1. Build a table using build datatable activity
  2. Add Get outlook mail message activity, You can use filter for your pending category like this “[Categories] = ‘Red category’”
    image
  3. In the for each loop you can calculate the pending since days for a pending category mail
    using
Pending_Since = (DateTime.Now.Date - currentItem.DateAsDateTime.Date).Days


4. Then you need to add this data in the datatable that we created which you can write it in any excel that you want using write datatable to excel

You will get ouput like this

Find attached the workflow for better understanding. It is better to replace the whole mail data in excel than comparing with existing data.

Mail.zip (10.5 KB)

Hope this helps :slight_smile:

Hi Thank you for this. The pending_since activity is giving me this error Assign: The given mail message does not specify a date.

Hi @srobey888

It is because the current mail don’t have a valid date value, you can skip these mails by using simpe if condition to check if date value is null or empty

Put this in If condition & go ahead only if this value is true.

IsNothing(currentItem.DateAsDateTime)

You can also assing date value if you want to process such mails.

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.