首页 > 解决方案 > 通过 c# 更改 Outlook 个人文具

问题描述

我刚刚开始学习如何使用 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;
    
}

标签: outlookvstooffice-interop

解决方案


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

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


推荐阅读