我正在尝试使用Python获取邮件的接收时间,但每次都会收到以下错误

时间:2019-12-13 10:33:39

标签: python python-3.x outlook message

import win32com.client,sys
from datetime import datetime
now=datetime.now()
outlook=win32com.client.Dispatch("Outlook.Application").GetNamespace("MAPI")
inbox=outlook.GetDefaultFolder(6)
messages=inbox.Items
message=messages.Getlast
received_time=str(message.ReceivedTime)
print(received_time)
received_time=datetime.strptime(received_time,"%m/%d/%y %H:%M:%S")
print(received_time)

错误:

  

回溯(最近通话最近):     在第29行的文件“ C:/ ... Outlook_Automation.py”中       receive_time = message.ReceivedTime.datetime.strftime(“%d-%m-%y%H:%M%p”)      getattr 中的文件“ C:\ Users .... \ AppData \ Local \ Programs \ Python \ Python37 \ lib \ site-packages \ win32com \ client \ dynamic.py”,行516       ret = self。 oleobj .Invoke(retEntry.dispid,0,invoke_type,1)   ValueError:小时必须在0..23

0 个答案:

没有答案