vba - Python Script to Turn Outlook E-Mail Rules on and Off -


i'm trying write python script/program turn off e-mail rules i've created in outlook 2010.

through vba, i've managed write function turn array of rule names on , off based on passed in boolean.

function togglerules(rulenames() string, tf boolean) boolean dim olrules outlook.rules dim olrule outlook.rule dim blnexecute boolean  each rule in rulenames()   set olrules = application.session.defaultstore.getrules   set olrule = olrules.item(rule)    olrule.enabled = tf    if blnexecute olrule.execute showprogress:=true     olrules.save    set olrules = nothing   set olrule = nothing next rule  end function 

this works, , turn on/off rules send name other vba functions. if you're curious, when task reminder subject fires call function.

i'd accomplish via python can trigger more sophistication reminder timers, , general cause i'd prefer way. seems can done pywin32 extension:

http://sourceforge.net/projects/pywin32/

however i'm having hard time trying rules interface. can outlook application , namespace, can't seem figure out go here.

import win32com.client x = win32com.client.gencache.ensuredispatch("outlook.application") y = x.getnamespace("mapi") 

ultimately i'd have same function, given list of names , bool, have toggle rules in outlook.

thanks.

the outlook object model common kind of applications (vba, com add-ins, automation , etc.). after got instance of namespace class can default store (or iterate on stores in profiles).

the defaultstore property of namespace class returns store object representing default store profile.

the stores property of namespace class returns stores collection object represents store objects in current profile.

finally, store class provides getrules method returns rules collection object contains rule objects defined current session.


Comments

Popular posts from this blog

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -