繁体   English   中英

如何使用 python 将 Outlook 中的每日电子邮件保存到文件夹中?

[英]How to save Emails of day from Outlook into a folder using python?

我一直在寻找一种方法来保存特定日期的 outlook 中的所有电子邮件,或者从一天开始到使用 python 将程序运行到本地文件夹的时间。 我们有什么办法可以做到这一点?

我相信,沿着这些路线的东西将是一个很好的起点:

import win32com.client

outlook = win32com.client.Dispatch("Outlook.Application").GetNamespace("MAPI")
msg = outlook.OpenSharedItem(r"C:\test_msg.msg")

print msg.SenderName
print msg.SenderEmailAddress
print msg.SentOn
print msg.To
print msg.CC
print msg.BCC
print msg.Subject
print msg.Body

count_attachments = msg.Attachments.Count
if count_attachments > 0:
    for item in range(count_attachments):
        print msg.Attachments.Item(item + 1).Filename

del outlook, msg

代码片段来自另一个线程,见下文

有关详细信息,请参阅Brent Edwards 的回答。

注意:如果您不使用 Outlook 客户端,您可以执行以下操作: https://stackoverflow.com/a/49681576/9814037

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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