How do I decide if an email was sent, sent, or sent?

I am using Visual Studio 2010 to create an Outlook 2007 Addin. Now I want to know if an email has been sent, sent or sent. 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
    }
}
+3
source share
2 answers

There are 3 advanced MAPI properties that relate to the status of the message for replying 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 is sent, the MailItem.Sent property will still be False.

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

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

, . , . olFolderSentMail.

0

Source: https://habr.com/ru/post/1784964/


All Articles