如何判断一封邮件是新发、回复还是转发?

发布于 2024-10-11 14:50:32 字数 1220 浏览 7 评论 0原文

我使用 Visual Studio 2010 创建 Outlook 2007 插件。现在我想知道一封电子邮件是新发送的、回复的还是转发的。有这个属性吗?

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
    }
}

I use Visual Studio 2010 to create an Outlook 2007 Addin. Now i want to know whether a e-mail was newly sent, replied or forwarded. Is there any property for this?

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
    }
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

江心雾 2024-10-18 14:50:32

有 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。

There are 3 Extended MAPI properties that deal with the message state for replied to/forwarded:

PR_ICON_INDEX (0x10800003)
PR_LAST_VERB_EXECUTED (0x10810003)
PR_LAST_VERB_EXECUTION_TIME (0x10820040)

To get these values in Outlook 2007/2010, use the PropertyAccessor Object:

http://msdn.microsoft.com/en-us/library/bb176395(office.12).aspx

If it's a send in progress, the MailItem.Sent property will still be False.

似最初 2024-10-18 14:50:32
MAPIFolder inbox = Application.Session.GetDefaultFolder(OlDefaultFolders.olFolderInbox);
Items unreadItems = inbox.Items.Restrict("[UnRead] = true");

foreach (MailItem mail in unreadItems)
{
    // Do Stuff
}

这似乎对我来说非常有效。我不知道邮件项目本身会有这些信息。您可以改为过滤 olFolderSentMail 文件夹。

MAPIFolder inbox = Application.Session.GetDefaultFolder(OlDefaultFolders.olFolderInbox);
Items unreadItems = inbox.Items.Restrict("[UnRead] = true");

foreach (MailItem mail in unreadItems)
{
    // Do Stuff
}

This seems to work really well for me. I don't know that the mailitem itself would have this information. You could filter the olFolderSentMail folder instead.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文