我想写一个Python脚本/程序关闭邮件规则我在Outlook 2010中Python脚本打开Outlook电子邮件规则和关闭
创建通过VBA,我我设法编写一个函数,它将根据传入的布尔值打开和关闭一组规则名称。
Function toggleRules(ruleNames() As String, tf As Boolean) As Boolean
Dim olRules As Outlook.Rules
Dim olRule As Outlook.Rule
Dim blnExecute As Boolean
For Each Rule In ruleNames()
Set olRules = Application.Session.DefaultStore.GetRules
Set olRule = olRules.Item(Rule)
olRule.Enabled = tf
If blnExecute Then olRule.Execute ShowProgress:=True
olRules.Save
Set olRules = Nothing
Set olRule = Nothing
Next Rule
End Function
这个工作,并会打开/关闭我发送它与其他VBA函数名称的规则。如果你很好奇,目前当某个主题的任务提示被触发时,它会调用这个函数。
我想通过python来实现这一点,所以我可以用更复杂的方式触发它,而不仅仅是提醒定时器,而只是一般的原因,我宁愿这样做。看来,它可以与pywin32扩展来完成:
http://sourceforge.net/projects/pywin32/
但是我有一个很难试图去规则接口。我可以进入Outlook应用程序和命名空间,但似乎无法弄清楚从哪里开始。
import win32com.client
x = win32com.client.gencache.EnsureDispatch("Outlook.Application")
y = x.GetNamespace("MAPI")
最后,我想基本上具有相同的功能,即给定的名称和一个布尔值的列表,有它在切换后市这些规则。
谢谢。