我正在使用 C# 为 Office 2007 创建一个插件。每当用户单击收件箱窗格中电子邮件列表中的电子邮件时,此插件负责在新窗格中显示电子邮件标题信息。现在我不确定当用户选择电子邮件并阅读该电子邮件标题信息时如何在收件箱窗格上获得鼠标单击事件。任何有用的指针?
问问题
1231 次
2 回答
0
您可以使用 Microsoft V11.0 Outlook 对象库(添加引用)然后查询 MAPI 邮箱:
http://geekswithblogs.net/TimH/archive/2006/05/26/79720.aspx 或 http://support.microsoft.com/kb/310258
使用 MAPI 或 POP3 访问交换收件箱的一些要求: C# MAPI 读取交换服务器收件箱
现在,要获取已选择的收件箱消息,您可以使用:
Outlook.Explorer explorer = null;
explorer = outlookObj.ActiveExplorer();
if (explorer.Selection.Count > 0)
{
var sel = explorer.Selection[1];
if (sel is Microsoft.Office.Interop.Outlook.MailItem)
{
var item = sel as MSOutlook.MailItem;
MessageBox.Show("Selected letter: "+item.Body);
}
}
于 2012-04-13T18:49:03.993 回答
0
private void ThisAddIn_Startup(object sender, System.EventArgs e)
{
this.Application.Inspectors.NewInspector += new Microsoft.Office.Interop.Outlook.InspectorsEvents_NewInspectorEventHandler(Inspectors_NewInspector);
}
void Inspectors_NewInspector(Microsoft.Office.Interop.Outlook.Inspector Inspector)
{
try
{
Outlook.MailItem tmpMailItem = (Outlook.MailItem)Inspector.CurrentItem;
if (tmpMailItem != null)
{
if (Inspector.CurrentItem is Outlook.MailItem)
{
tmpMailItem = (Outlook.MailItem)Inspector.CurrentItem;
string to= tmpMailItem.To;
string body = tmpMailItem.Body;
}
}
}
catch
{
}
}
于 2013-01-11T11:35:39.747 回答