简体   繁体   中英

Python MAPI Outlook read emails for a particular year

This func is for Year alone. (Doesn't work)

def daterange(args):
        
        user_inp = datetime.strptime(args,'%Y')

        rmail = object.Restrict("[ReceivedTime] == '" + user_inp.strftime('%Y')+"'")
        return rmail

The Restrict code doesn't work with =, throws error with == and only works with >=

My requirement is all mails from user_inp(2020) or 2019 etc

Please Help !!!

The Restrict code doesn't work with =, throws error with == and only works with >=

Using the equal operator is not really a good idea. Instead, you need to specify the time and date range. The difference can be a minute, but not equal.

Read more about the date and time comparisons in Outlook on the Filtering Items Using a Date-time Comparison page.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM