【问题标题】:Change Outlook Personal Stationery via c#通过 c# 更改 Outlook 个人文具
【发布时间】:2021-06-10 13:17:23
【问题描述】:

我刚刚开始学习如何使用 Visual Studio 为 Outlook 编写加载项。我很难找到资源来阅读 VSTO。 Outlook 个人文具下的“新邮件”和“回复或转发邮件”如何不能修改默认字体?


修改了我的帖子以包含解决方案:

我正在使用此链接 (https://pcloadletter.co.uk/2010/05/19/outlook-default-font-and-signature/) 中的代码并转换为 c#。对于那些尝试这样做的人,这就是我的做法。

private void SetFont()
{
    RegistryKey key = Registry.CurrentUser.OpenSubKey(@"SOFTWARE\Microsoft\Office\16.0\Common\MailSettings", true);

    // set the font in Outlook and then export it from the registry. Use that value for our code.
    string ComposeFontSimple = @"3c,00,00,00,1f,00,00,f8,00,00,00,00,c8,00,00,00,00,00,
                        00,00,ff,ff,00,dd,00,22,41,72,69,61,6c,00,00,00,00,00,00,00,00,00,00,00,00,
                        00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00";
    byte[] arrComposeFontSimpleBin = ArrayHexToDec(ComposeFontSimple.Split(','));
    key.SetValue("ComposeFontSimple", arrComposeFontSimpleBin, RegistryValueKind.Binary);
}

public static byte[] ArrayHexToDec(string[] arrHex)
{
    byte[] arrDec = new byte[arrHex.GetUpperBound(0)];

    for (int i = 0; i < arrHex.GetUpperBound(0); i++)
    {
        if (arrHex[i] == "00")
        {
            arrDec[i] = 0;
        }
        else
        {
            arrDec[i] = byte.Parse(arrHex[i], System.Globalization.NumberStyles.HexNumber);
        }
    
    }           
    
    return arrDec;
    
}

【问题讨论】:

    标签: outlook vsto office-interop


    【解决方案1】:

    设置存储在HKCU\Software\Microsoft\Office\%s.0\Common\MailSettings。

    您想要的值是ReplyFontSimple - 字体大小从偏移量 12 开始,名称从偏移量 0x1A(0x0 终止的字符串)开始。

    【讨论】:

    • 谢谢!我使用注册表项让它工作。最初,我正在寻找 Outlook API,但它会为我工作。
    【解决方案2】:

    Outlook 将其设置保留在 Windows 注册表中。尝试使用 Process Monitor 跟踪 Outlook 将其设置保存在何处。

    如果我们谈到在运行时对 Outlook 邮件项目进行更改,则可以使用三种不同的方式修改邮件正文:

    1. Body
    2. HTMLBody
    3. Word 编辑器。 Inspector 类的WordEditor 属性返回代表消息正文的Word 文档实例。

    请参阅Chapter 17: Working with Item Bodies 了解更多信息。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-06-28
      • 1970-01-01
      • 2011-03-03
      • 2015-04-29
      • 1970-01-01
      • 2018-03-25
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多