How to convert mail.headers("Date") to a datetime variable to compare to now.adddays(-1)

Can anyone help me with an issue of trying to get a date from an email and then compare it to “now”? Essentially what i am trying to do is move all emails from folder to deleted items folder that are older than 1 day. My thought was to grab mail.headers(“date”) and compare it to now.adddays(-1) and anything less than that gets moved, but mail.headers is a string so I am having issues. I am open to another method if need be.



You can convert string to date like below:

DateTime.ParseExact(“05/04/2019”, “dd/MM/yyyy”,

Thanks I think i have it now. I made a mistake on my get outlook messages as well which made it harder to trouble should. Thanks again for the quick response!

1 Like

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