繁体   English   中英

如何决定是否新发送,回复或转发电子邮件?

[英]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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM