【发布时间】:2021-10-19 09:03:29
【问题描述】:
C#、VSTO、Outlook 2016。
我想获取 Outlook 中所有打开的 Inspector 的标题列表。
第一次调用 Outlook.Application.Inspectors[1].Caption 返回“Message”作为检查器标题。 但是检查员的窗口标题显示了电子邮件的主题。
但是当我打开更多检查器时,标题似乎会改变。
所以集合中总是有一个检查员没有 电子邮件主题和 Inspector.Caption 与对应的不匹配 窗口标题。
那么我怎样才能得到正确的窗口标题列表呢?
对应代码:
private void ThisAddIn_Startup(object sender, System.EventArgs e)
{
m_Application = this.Application as Outlook.Application;
m_Inspectors = m_Application.Inspectors;
m_Inspectors.NewInspector += new Outlook.InspectorsEvents_NewInspectorEventHandler(m_Inspectors_NewInspector);
void m_Inspectors_NewInspector(Outlook.Inspector Inspector) {
if (Application.Inspectors.Count > 0) {
Debug.WriteLine("\n=== [Test] ================================");
Debug.WriteLine($" Inspectors.Count: {Application.Inspectors.Count}");
Debug.WriteLine(" Application.Inspectors: ");
foreach (Outlook.Inspector CurrentInspector in Application.Inspectors) {
Debug.WriteLine($" {CurrentInspector.Caption}");
Debug.WriteLine($" --> {CurrentInspector.CurrentItem.Subject}");
}
Debug.WriteLine("===========================================\n");
}
}
}
【问题讨论】:
标签: c# outlook outlook-addin