我是一个全新的我试图下载附件使用MAPI的基础上日期,发件人的电子邮件地址和主题行。你知道吗
下面是我的代码:
import datetime
from win32com.client import Dispatch
outlook = Dispatch("Outlook.Application").GetNamespace("MAPI")
inbox = outlook.GetDefaultFolder("6")
all_inbox = inbox.Items
folders = inbox.Folders
val_date = datetime.date.today().strftime("%d-%m-&y")
today = msg.Senton.date() = val_date
inboxtime = all_inbox and today
email_sender = 'Email input here'
sub_today = 'Subject line input here'
att_today = 'attachment name input here'
for msg in inboxtime:
if msg.SenderEmailType == "EX":
if msg.Sender.GetExchangeUser().PrimarySmtpAddress.find(email_sender) != -1
break
else:
if msg.SenderEmailAddress.find(email_sender) != -1 and msg.Senton.date() == val_date:
break
For att in msg.Attachments:
if att.FileName == att_today:
break
try:
att.SaveAsFile('D:\\' + att.FileName)
print(True)
except:
print(False)
但是,它显示以下错误:
today= msg.Senton.date() == val_date
AttributeError: 'str' object has no attribute 'Senton'
请帮帮我!你知道吗
首先,这不是MAPI-这是Outlook对象模型。其次,假设收件箱文件夹中只有
MailItem
对象,但也可以有ReportItem
、MeetingItem
等。首先确保确实有MailItem
对象-检查Class
属性==43(olMailItem
)相关问题 更多 >
编程相关推荐