以编程方式设置 Outlook 2013 签名默认值?

2024-04-29

是否可以通过编程方式设置 Outlook 2013 默认签名设置?我们可以生成用户的签名,但还想将签名设置为默认显示在用户的电子邮件中:

该设置本身似乎隐藏在 Outlook 配置文件下的注册表中:

HKEY_CURRENT_USER\Software\Microsoft\Office\15.0\Outlook\Profiles\Outlook\9375CFF0413111d3B88A00104B2A6677\00000002

注册值:

  • New Signature
  • Reply-Forward Signature

...(其中包含二进制数据,可能对 HTML 文件名/引用进行编码)。

不确定是否可以使用 Outlook 对象模型来访问和设置设置?这对于 ClickOnce 应用程序是否可行?


我还没有清理代码,但这对我来说可以在 Outlook 2013 中设置签名。在 python 中(是的,我知道它很难看,而不是 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')
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

以编程方式设置 Outlook 2013 签名默认值? 的相关文章

随机推荐