![](/img/trans.png)
[英]Outlook 2010 Add-In: How to customize “From/To/CC/Subject” pane?
[英]Outlook 2010 Add-in - How to determine which MailItem is being shown in the “Reading Pane”
我正在尝试编写Outlook 2010加载项,该加载项会将电子邮件从收件箱移动到各种存档文件夹(基于一组过滤条件)。
我的主要目标是让我所有的新电子邮件都到达我的收件箱,并且仅在将其标记为已读并且不再显示在“阅读窗格”中时才移动。
在“阅读窗格”中显示新邮件项目时,是否有事件处理程序?
这些接口之一可以帮助:
Microsoft.Office.Interop.Outlook.Items
Microsoft.Office.Interop.Outlook.Explorers
Microsoft.Office.Interop.Outlook.Inspectors
Outlook.NavigationPane
您可以使用Explorer.SelectionChange
事件来查看何时选择了特定消息(并且取消选择了旧消息)。
我使用了Explorer.SelectionChange
事件,它成功了。 这是选择新项目时打印电子邮件主题的代码。
Outlook.Explorer explorer;
private void ThisAddIn_Startup(object sender, System.EventArgs e)
{
explorer = Application.ActiveExplorer();
explorer.SelectionChange += new Outlook.ExplorerEvents_10_SelectionChangeEventHandler(explorer_SelectionChange);
}
void explorer_SelectionChange()
{
if(0 == Application.ActiveExplorer().Selection.Count)
{
// On start up there are no selections so do nothing...
return;
}
// Get the first mail item
var item = Application.ActiveExplorer().Selection[1];
//
if (item is Outlook.MailItem)
{
MessageBox.Show("Selected email's subject: " + ((Outlook.MailItem)item).Subject);
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.