我正在 Outlook 2016 中编写 VSTO,我想根据用户的“开始新消息”或仅打开/阅读消息的操作来启用/禁用功能区中的按钮。
我的问题是如何检测用户何时按下“新邮件”或仅打开发送/接收的一条消息。
有人可以帮助我吗? 谢谢!
最佳答案
This tutorial实际上处理的是这个确切的场景:
private void ThisAddIn_Startup(object sender, System.EventArgs e)
{
inspectors = this.Application.Inspectors;
inspectors.NewInspector +=
new Microsoft.Office.Interop.Outlook.InspectorsEvents_NewInspectorEventHandler(Inspectors_NewInspector);
}
具体来说,您附加到 this.Appliaction.Inspectors
。本教程借此机会修改新 MailItem
的 Subject
和 Body
属性:
void Inspectors_NewInspector(Microsoft.Office.Interop.Outlook.Inspector Inspector)
{
Outlook.MailItem mailItem = Inspector.CurrentItem as Outlook.MailItem;
if (mailItem != null)
{
if (mailItem.EntryID == null)
{
mailItem.Subject = "This text was added by using code";
mailItem.Body = "This text was added by using code";
}
}
}
关于vsto - 如何检测用户何时在 Outlook VSTO 中选择“新建”或“打开”邮件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50342840/