Python MAPI Outlook 读取特定年份的电子邮件

Python MAPI Outlook read emails for a particular year

此函数仅适用于 Year。 (不起作用)

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

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

Restrict 代码不适用于 =,抛出错误 == 并且仅适用于 >=

我的要求是 user_inp(2020) 或 2019 等

的所有邮件

请帮忙!!!

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

使用 equal 运算符并不是一个好主意。相反,您需要指定时间和日期范围。可以相差一分钟,但不相等。

Filtering Items Using a Date-time Comparison 页面上阅读有关 Outlook 中日期和时间比较的更多信息。