Hi, i would like to get outlook mails by yesterday on current day. i have fill as below but seems i missed something. May help to advise what is the correct code for get the filter 1 day before emails?
“[ReceivedTime] >= '” + DateTime.Now.AddDays(-1).ToString(“MM/dd/yyyy”) + “’ AND [ReceivedTime] < '” + DateTime.Now.ToString(“MM/dd/yyyy”) + “'”
Hope it helps!!
Sequence:
Assign activity: yesterday = Now.AddDays(-1)
Get Outlook Mail Messages activity:
Account: “Your Outlook Account”
MailFolder: “Inbox”
Filter: “[ReceivedTime] >= '” + yesterday.ToString(“MM/dd/yyyy”) + “’ AND [ReceivedTime] < '” + Now.ToString(“MM/dd/yyyy”) + “'”
For Each activity (TypeArgument: MailMessage):
// Process each email here, for example, you can log the email subject and received time
Log Message: "Email Subject: " + item.Subject + ", Received Time: " + item.Headers(“Date”)
Try the below simple C# to filter with the yesterday received mails.
"[ReceivedTime] >= '" + DateTime.Now.AddDays(-1).ToString("MM/dd/yyyy")
Hope it helps!!
Thank you @balaraj.pubalan
If you find the solution do mark it as solution to close the loop.
Happy Automation!!
Try this:
“[ReceivedTime] >= '” + DateTime.Now.AddDays(-1).ToString(“MM/dd/yyyy 00:00 AM”) + “’ AND [ReceivedTime] <= '” + DateTime.Now.AddDays(-1).ToString(“MM/dd/yyyy 11:59 PM”) + “'”
May i know why i get this error?
Get Outlook Mail Messages: Cannot parse condition. Error at “'07/20/2023 14:06"”.
use this format in place of that:
“07/20/2023 14:06:00”
Added as below and its works as per my expectation:
“[ReceivedTime] < '” + DateTime.Now.AddDays(-1).ToString(“MM/dd/yyyy hh:mm”) + “'”
Thanks.
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.