O365 Get Mail - Queries


Have scanned every resource I know - and both UiPath and MS documentation I feel somewhat lacking here - how do I use the query/filter here to get emails from last x number of hours?

All I can find is hard coded days/dates which people have given as solutions (which are useless) and converting those over to variables just gives a string of errors even though using a log message to print the query beforehand shows it looking exactly like their hard coded lines.

“ReceivedDateTime ge '” + datetime.Now.AddHours(-6).tostring(“yyyy-MM-ddTHH:mm”) + “'”
prints as:
ReceivedDateTime ge ‘2021-10-05T06:35’

Get Mail: Code: BadRequest
Message: Invalid filter clause
Inner error:
date: 2021-10-05T16:44:38

Any help here with this would be greatly appreciated.


Think I’ve sorted it!

"receivedDateTime ge " + datetime.Now.AddHours(-6).tostring(“yyyy-MM-ddTHH:mm:ssZ”)

This seems to not throw any errors :slight_smile:

1 Like

Hi @Alex_Cross,

Its good to hear that :slight_smile:

So now that your issue is resolved, I would suggest to mark solution so this topic can be closed.


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