我使用Visual Studio 2010创建Outlook 2007 Addin。现在我想知道是否新发送,回复或转发了电子邮件。这有什么属性吗?
using Outlook = Microsoft.Office.Interop.Outlook;
namespace _Outlook2k7_Add_In
{
public partial class ThisAddIn
{
private void ThisAddIn_Startup(object sender, System.EventArgs e)
{
}
private void ThisAddIn_Shutdown(object sender, System.EventArgs e)
{
}
void Application_ItemSend(object Item, ref bool Cancel)
{
Outlook.MailItem mail = Item as Outlook.MailItem;
if (mail == null)
return;
// Magic?
}
#region VSTO generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InternalStartup()
{
this.Startup += new System.EventHandler(ThisAddIn_Startup);
this.Shutdown += new System.EventHandler(ThisAddIn_Shutdown);
this.Application.ItemSend += new Outlook.ApplicationEvents_11_ItemSendEventHandler(Application_ItemSend);
}
#endregion
}
}
答案 0 :(得分:1)
有3个扩展MAPI属性可处理回复/转发的消息状态:
PR_ICON_INDEX(0x10800003) PR_LAST_VERB_EXECUTED(0x10810003) PR_LAST_VERB_EXECUTION_TIME(0x10820040)
要在Outlook 2007/2010中获取这些值,请使用PropertyAccessor对象:
http://msdn.microsoft.com/en-us/library/bb176395(office.12).aspx
如果是正在发送的邮件,则MailItem.Sent属性仍为False。
答案 1 :(得分:0)
MAPIFolder inbox = Application.Session.GetDefaultFolder(OlDefaultFolders.olFolderInbox);
Items unreadItems = inbox.Items.Restrict("[UnRead] = true");
foreach (MailItem mail in unreadItems)
{
// Do Stuff
}
这对我来说似乎很有效。我不知道mailitem本身会有这些信息。您可以过滤 olFolderSentMail 文件夹。