Mar*_*nto 2 outlook loops python-2.7
我正在尝试创建一个脚本,将每天上午 8:00 起所有 Outlook 发送的项目转发到专用收件箱。
该邮件必须保存在 Outlook 的已发送邮件文件夹中。
目前我拥有今天的所有电子邮件,但脚本的转发部分不起作用(我没有任何错误消息)
编辑 1:感谢吉米的限制想法!
import win32com.client as win32
outlook = win32.Dispatch("Outlook.Application").GetNamespace("MAPI")
outbox = outlook.GetDefaultFolder(6)
messages = messages = outbox.Items.restrict("[SentOn] > '5/31/2017 08:00 AM'")
for message in messages:
NewMsg = message.Forward()
NewMsg.To = "mail@mail.com"
Run Code Online (Sandbox Code Playgroud)
已完成:有兴趣的可以在下面找到解决方案
import win32com.client as win32
outlook = win32.Dispatch("Outlook.Application").GetNamespace("MAPI")
outbox = outlook.GetDefaultFolder(5)
messages = outbox.Items.restrict("[SentOn] > '5/30/2017 08:00 AM'")
for message in messages:
NewMsg = message.Forward()
NewMsg.Body = message.Body
NewMsg.Subject = message.Subject
NewMsg.To = "mail@mail.com"
NewMsg.Send()
Run Code Online (Sandbox Code Playgroud)