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