Programmatically set Outlook 2013 Signature Defaults?

风流意气都作罢 提交于 2019-12-03 16:29:05

I haven't cleaned up the code yet, but this works for me to set the signature in Outlook 2013. In python (yes I know its ugly and not PEP8).

import _winreg
def set_default():

    try:
        #this makes it so users can't change it.
        outlook_2013_key = _winreg.OpenKey(_winreg.HKEY_CURRENT_USER, r"Software\Microsoft\Office\15.0\Common\MailSettings", 0, _winreg.KEY_ALL_ACCESS)
        _winreg.SetValueEx(outlook_2013_key, "NewSignature", 0, _winreg.REG_SZ, "default" )
        _winreg.SetValueEx(outlook_2013_key, "ReplySignature", 0, _winreg.REG_SZ, "default" )

        # sets the sigs in outlook profile
        outlook_2013_base_key = _winreg.OpenKey(_winreg.HKEY_CURRENT_USER, r"Software\Microsoft\Office\15.0\Outlook\Profiles", 0, _winreg.KEY_ALL_ACCESS)
        default_profile_2013_tup = _winreg.QueryValueEx(outlook_2013_base_key,'DefaultProfile')
        default_profile_2013 = default_profile_2013_tup[0]
        print default_profile_2013
        outlook_2013_profile_key = _winreg.OpenKey(_winreg.HKEY_CURRENT_USER,
                                                   "Software\\Microsoft\\Office\\15.0\\Outlook\\Profiles\\" + default_profile_2013 + "\\9375CFF0413111d3B88A00104B2A6676", 0, _winreg.KEY_ALL_ACCESS)
        for i in range(0, 10):
            try:
                outlook_2013_sub_key_name = _winreg.EnumKey(outlook_2013_profile_key,i)
                print outlook_2013_sub_key_name, "sub_key_name"
                outlook_2013_sub_key = _winreg.OpenKey(outlook_2013_profile_key, outlook_2013_sub_key_name, 0, _winreg.KEY_ALL_ACCESS)
                _winreg.SetValueEx(outlook_2013_sub_key, "New Signature", 0, _winreg.REG_SZ, "default" )
                _winreg.SetValueEx(outlook_2013_sub_key, "Reply-Forward Signature", 0, _winreg.REG_SZ, "default" )
            except:
                pass

    except:
        print('no 2013 found')

Outlook signatures are set on the per account basis in profile data (stored in the registry). You can see the data in OutlookSpy - click IOlkAccountManager button and double click on the account.

IOlkAccountManager can be accessed only in C++ or Delphi. If using Redemption is an option (it can be used from any language, including VBA or .Net, I am its author), it exposes the RDOAccount.ReplySignature and NewMessageSignature properties.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!