Using python and win32com to write outlook rules
mabel juhi 3 years ago • updated by Rafał Strzaliński (Senior Engineer) 3 years ago • 2
I've been trying really hard to make it work in python 3.7 and outlook 365. A related question here and the VBA documentation is here. I can't manage to solve it.
Everything in the code is working fine, except the two lines commented out in the code.
import win32com.client as win32 o = win32.Dispatch("Outlook.Application") musterman = o.GetNamespace("MAPI").Folders['firstname.lastname@example.org'] dest_folder = musterman.Folders["Posteingang"].Folders["Ich"] colRules = o.Session.DefaultStore.GetRules() oRule = colRules.Create("New Rule", 0) oFromCondition = oRule.Conditions.From oFromCondition.Enabled = True oFromCondition.Recipients.Add("email@example.com") oFromCondition.Recipients.ResolveAll oMoveRuleAction = oRule.Actions.MoveToFolder oMoveRuleAction.Enabled = True #not working oMoveRuleAction.Folder = dest_folder #not working colRules.Save()
Customer support service by UserEcho
We're familiar with Python, but not with Office 365. Please ask you question on https://stackoverflow.com . There is a community which can help you, for example: https://stackoverflow.com/search?q=office+365