Issue Summary
I am experiencing an issue with filtering emails by date using the Get Exchange Mail Messages
activity in UiPath. Specifically, I want to retrieve emails from a specific day only. However, the filtering does not seem to work as expected, and emails from different dates are being retrieved.
Problem Description
I am using the following filter to retrieve emails from a specific day:
"received:" + DateTime.Today.AddDays(-5).ToString("yyyy-MM-dd")
For example, if today’s date is August 12, 2024, the filter should retrieve emails from August 7, 2024. However, emails from August 9, 2024, are being retrieved instead. This suggests that the filter is not correctly limiting the emails to those received on the specified date.
Previous Working Approach
In a previous implementation using the Get Outlook Mail Messages
activity, I successfully used the following filter, which worked as expected:
"[ReceivedTime] >= '" + DateTime.Today.AddDays(-IntDniStart).ToString("d") + " 00:00AM' AND [ReceivedTime] < '"+ DateTime.Today.AddDays(-IntDniEnd).ToString("d") + " 00:00AM'"
This filter correctly retrieved emails within the specified date range when used with the Outlook activity.
Tested Solutions
-
Simple Date Filter (Initial Approach)
- Filter Used:
"received:" + DateTime.Today.AddDays(-5).ToString("yyyy-MM-dd")
- Result: Emails from outside the specified date (e.g., emails from August 9, 2024) are being retrieved. This filter does not seem to work correctly, possibly due to incorrect interpretation of the date range or timezone issues.
- Filter Used:
-
Exact Date and Time Range Filter
- Filter Used:
"received>= " + DateTime.Today.AddDays(-5).ToString("yyyy-MM-ddT00:00:00Z") + " AND received< " + DateTime.Today.AddDays(-4).ToString("yyyy-MM-ddT00:00:00Z")
- Result: Even with a more precise time range, the issue persists. Emails from unintended dates are still being retrieved. This suggests that the server might be interpreting the filter differently, possibly due to time zone differences or incorrect date handling.
- Filter Used:
-
Consideration of Timezone Differences
- Adjustments Tested:
- Tried shifting the filter range to account for possible timezone differences between the server and local time.
- Used UTC (Coordinated Universal Time) format to eliminate timezone discrepancies.
- Result: Despite these adjustments, the problem persists, and the filter does not limit the emails to the exact date range specified.
- Adjustments Tested:
Request for Support
Given the tests conducted and the continued issues with incorrect email retrieval, it appears there might be an underlying issue with how the Get Exchange Mail Messages
activity or the server interprets date filters. This is especially perplexing because a similar filter worked perfectly in the Get Outlook Mail Messages
activity. I need assistance in diagnosing and resolving this problem to ensure that emails are correctly filtered by the specified date.