キーが電子メールアドレスで、値がファイルパスであるディクショナリオブジェクトを作成することで、これを解決しました。
private Dictionary<string, string> signatureDictionary()
{
string sigDataDir = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + @"\Microsoft\Signatures";
Dictionary<string, string> returnValue = new Dictionary<string,string>();
Microsoft.Win32.RegistryKey key = Microsoft.Win32.Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Windows NT\CurrentVersion\Windows Messaging Subsystem\Profiles\Outlook\9375CFF0413111d3B88A00104B2A6676", false);
string[] str = key.GetSubKeyNames();
foreach (string s in str)
{
Microsoft.Win32.RegistryKey subKey = key.OpenSubKey(s, false);
if (subKey.GetValue("New Signature") != null)
{
returnValue.Add(System.Text.Encoding.Unicode.GetString(subKey.GetValue("Account Name") as
Byte[],0,(subKey.GetValue("Account Name") as Byte[]).Length - 2)
, Path.Combine(sigDataDir,System.Text.Encoding.Unicode.GetString(
subKey.GetValue("New Signature") as Byte[], 0, (subKey.GetValue("New Signature") as
Byte[]).Length - 2) + @".rtf"));
}
}
key.Close();
return returnValue;
}
同様の質問に対するこの回答は、最初に私を正しい方向に導き、「新しい署名」キーは、そのアカウントに署名が設定されている場合にのみ入力されることを理解しました。間違いなくこれがうまくいかない状況があるでしょうが、それは私の現在の問題のためにそれを整理します. 私は VSTO でメールを編集するときに WordEditor を使用するので、この関数では RTF ファイルを使用しますが、同じディレクトリに .HTM および .TXT ファイルもあるので、必要に応じてそれらを使用できます。