none
Outlook Office 2003 - custom event handlers AddItem ? RRS feed

  • Question

  • Hello experts,

    is it possible on VSTO for Office 2003 to handle an event when a mail is added on "sent items" folder ?

    i'm trying to move a mail just sent by a user to an other "sent Items" folder from another mail box ...

    thank you for you help or ideas !

    Wednesday, May 16, 2012 10:43 AM

Answers

  • change Outlook.Folder to Outlook.MAPIFolder - in 2003 Folder object was not yet introduced. Everything else should be the same.
    • Marked as answer by Nabil BO Friday, May 18, 2012 8:17 AM
    Wednesday, May 16, 2012 1:14 PM

All replies

  • you should handle ItemAdd event on Items object on SentItems folder. Did you try this?

    Wednesday, May 16, 2012 11:11 AM
  • DamianD, Thank you for your answer !

    I tried this code made by Bessie Zhao from  http://social.msdn.microsoft.com/Forums/en-US/vsto/thread/d90f159e-c423-4977-a71f-688cfbd1ba38

    But i have not the object "Outlook.Folder" in my Framework  (VSTO 2005 SE)

     Outlook.Items items;
            private void ThisAddIn_Startup(object sender, System.EventArgs e)
            {
                Outlook.Folder folder = Globals.ThisAddIn.Application.Session.GetDefaultFolder(Microsoft.Office.Interop.Outlook.OlDefaultFolders.olFolderSentMail) as Outlook.Folder;
                items = folder.Items;
                items.ItemAdd += new Microsoft.Office.Interop.Outlook.ItemsEvents_ItemAddEventHandler(items_ItemAdd);
            }

            void items_ItemAdd(object Item)
            {
                try
                {
                    Outlook.MailItem mail = Item as Outlook.MailItem;
                    MessageBox.Show("...");
                }
                catch (Exception ex)
                {
                   
                }
            }

    • Edited by Nabil BO Wednesday, May 16, 2012 1:01 PM
    Wednesday, May 16, 2012 12:45 PM
  • change Outlook.Folder to Outlook.MAPIFolder - in 2003 Folder object was not yet introduced. Everything else should be the same.
    • Marked as answer by Nabil BO Friday, May 18, 2012 8:17 AM
    Wednesday, May 16, 2012 1:14 PM
  • Thank you DamianD ! :)

    it works with Outlook.MAPIFolder in 2003 !!

    Friday, May 18, 2012 8:18 AM