[英]How decide whether a e-mail was newly sent, replied or forwarded?
我使用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
}
}
有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。
MAPIFolder inbox = Application.Session.GetDefaultFolder(OlDefaultFolders.olFolderInbox);
Items unreadItems = inbox.Items.Restrict("[UnRead] = true");
foreach (MailItem mail in unreadItems)
{
// Do Stuff
}
這對我來說似乎很有效。 我不知道mailitem本身會有這些信息。 您可以過濾olFolderSentMail文件夾。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.