Microsoft Outlook创建规则运行应用程序脚本Python

Microsoft Outlook创建规则运行应用程序脚本Python,第1张

Microsoft Outlook创建规则运行应用程序/脚本Python

如果您可以简单地从python完成所有 *** 作,为什么要在Outlook中创建运行脚本的规则(如果收到电子邮件)。

使用Python监视所有传入电子邮件的外观,然后执行某些代码(如果可以接收到主题为%BLAHBLAH%的电子邮件)。这是一个例子:

import win32com.clientimport pythoncomimport reclass Handler_Class(object):    def onNewMailEx(self, receivedItemsIDs):        # RecrivedItemIDs is a collection of mail IDs separated by a ",".        # You know, sometimes more than 1 mail is received at the same moment.        for ID in receivedItemsIDs.split(","): mail = outlook.Session.GetItemFromId(ID) subject = mail.Subject try:     # Taking all the "BLAHBLAH" which is enclosed by two "%".      command = re.search(r"%(.*?)%", subject).group(1)     print command # Or whatever pre you wish to execute. except:     passoutlook = win32com.client.DispatchWithEvents("Outlook.Application", Handler_Class)#and then an infinit loop that waits from events.pythoncom.PumpMessages()


欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/zaji/5645775.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-12-16
下一篇2022-12-16

发表评论

登录后才能评论

评论列表(0条)

    保存