使用
comtypes.client代替,
win32com.client您可以执行以下操作:
import comtypes.cliento = comtypes.client.CreateObject("Outlook.Application")rules = o.Session.DefaultStore.GetRules()rule = rules.Create("Python rule test", 0 ) # 0 is the value for the parameter olRuleReceivecondition = rule.Conditions.Subject # I guess MessageHeader works toocondition.Text = ('Foo', 'Bar')condition.Enabled = Trueroot_folder = o.GetNamespace('MAPI').Folders.Item(1)foo_folder = root_folder.Folders['Notifications'].Folders['Foo']move = rule.Actions.MoveToFoldermove.__MoveOrCopyRuleAction__com__set_Enabled(True) # Need this line otherwise # the folder is not set in outlookmove.__MoveOrCopyRuleAction__com__set_Folder(foo_folder) # set the destination folderrules.Save() # to save it in Outlook我知道不是用win32com.client,也不是用IronPython!



