none
BeforeItemMove in Outlook 2010 Additional Mailbox Folder RRS feed

  • Question

  • Hi,

    I am aware of numerous problems of BeforeItemMove event not triggering in Outlook 2010 that were fixed eventually. I have Outlook 2010 Professional Plus SP1. However I am having a problem that I couldn't resolve til now. I added an additional Mailbox to Outlook. It is a Mailbox of a another user used for support. The problem is that the BeforeItemMove event is only triggering once for Folders inside this additional Mailbox. any subsequent moves from these folders do not trigger the event. I am using a global list of wrapper folders where the events handlers are implemented. I know the wrapper is working correctly since any other folder outside this additional Mailbox works as expected. Events keep on triggering in folders of my default mailbox and of pst files without any problems. Note that the problem is not appearing in Outlook 2007 but only in Outlook 2010. Thank you.

    Saturday, March 17, 2012 9:51 AM

All replies

  • What are the relevant snippets of your code?

    Does the event get triggered if you look at the folder in OutlookSpy? Go to the folder in question, click "Folder" button on the OutlookSpy toolbar/ribbon, go to the Events tab.


    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.2 is now available!

    Saturday, March 17, 2012 5:01 PM
  • I tried Outlook spy, the event triggers the first time only as i described. Please note that the wierd thing is that the event triggers more than once on all other folders in other stores. it is only the store of the Additional Mailbox that has the problem. Code snippet below:

    namespace VBCOutlook
    {
        public partial class VBCAddIn
        {
            private static Configuration config = null;
            private List<GlobalFolderWrapper> allFolders= null;
    
            private void VBCAddIn_Startup(object sender, System.EventArgs e)
            {
                try
                {
                    config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
    
                    allFolders = new List<GlobalFolderWrapper>();
                    foreach(Outlook.Store store in Application.Session.Stores)
                    {
                        foreach (Outlook.Folder folder in store.GetRootFolder().Folders)
                        {
                            if (!Boolean.Parse(config.AppSettings.Settings["DELETEITEM"].Value))
                                allFolders.Add(new GlobalFolderWrapper(folder,config));
                        }
                    }
    
                 }
                catch (System.Exception ex)
                {
                    MessageBox.Show("Error: " + ex.Message, "VBC Outlook", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
    
    

    namespace VBCOutlook
    {
        internal class GlobalFolderWrapper
        {
            Outlook.Folder folder;
            Configuration config;
            
    
            public GlobalFolderWrapper(Outlook.Folder folder, Configuration config)
            {
                this.config = config;
                this.folder = folder;
                this.folder.BeforeItemMove += new MAPIFolderEvents_12_BeforeItemMoveEventHandler(folder_BeforeItemMove);
            }
    
            void folder_BeforeItemMove(object Item, MAPIFolder MoveTo, ref bool Cancel)
            {
                MessageBox.Show("Entered Event");
                    
                
            }
    
            public Outlook.Folder Folder { get { return folder; } }

    Saturday, March 17, 2012 6:53 PM
  • Hi 3ala2,

    Thanks for posting in the MSDN Forum.

    I don't think only the folders which under root folder have subcribed the BeforeItemMove event. If you have sub folder in these folder the event will not fire. And I tried you snippet on my side. I works fine. According to your description, the following snippet will work.

    using System.Text;
    using System.Xml.Linq;
    using Outlook = Microsoft.Office.Interop.Outlook;
    using Office = Microsoft.Office.Core;
    using System.Configuration;
    using System.Windows.Forms;
    
    namespace OutlookAddIn2
    {
        public partial class OutlookAddIn2
        {
            private static Configuration config = null;
            private List<GlobalFolderWrapper> allFolders = null;
    
            protected override Microsoft.Office.Core.IRibbonExtensibility CreateRibbonExtensibilityObject()
            {
                return new Ribbon1();
            }
    
            private void OutlookAddIn2_Startup(object sender, System.EventArgs e)
            {
                try
                {
                    config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
                    allFolders = new List<GlobalFolderWrapper>();
                    foreach (Outlook.Store store in Application.Session.Stores)
                    {
                        Iterator((Outlook.Folder)store.GetRootFolder(),ref allFolders);
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Error: " + ex.Message+"\n"+ex.StackTrace, "VBC Outlook", MessageBoxButtons.OK, MessageBoxIcon.Error);
    
                }
            }
    
            private void Iterator(Outlook.Folder folder,ref List<GlobalFolderWrapper> list)
            {
                foreach (Outlook.Folder element in folder.Folders)
                {
                    list.Add(new GlobalFolderWrapper(element, config));
                    if (element.Folders.Count > 0)
                    {
                        Iterator(element, ref list);
                    }
                }
            }
    
            private void OutlookAddIn2_Shutdown(object sender, System.EventArgs e)
            {
            }
    
            #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(OutlookAddIn2_Startup);
                this.Shutdown += new System.EventHandler(OutlookAddIn2_Shutdown);
            }
            
            #endregion
        }
    }

    However, I afraid you will wast a great deal of time on subscribe the event.

    Have a good day,

    Tom


    Tom Xu [MSFT]
    MSDN Community Support | Feedback to us

    Tuesday, March 20, 2012 6:29 AM
    Moderator
  • Hi Tom,

    Thanks for your reply. What i did was on purpose, I did not want to add the event on all folders but only first level folders under all the stores. The problem is only the additional Mailbox. As i said before, it is working perfectly on Outlook 2007 but only triggers once on Outlook 2010. Is it possible that Outlook 2010 treats the additional Mailbox differently in terms of events? I will try adding events to all folders recursively as the code you presented and check.

    Tuesday, March 20, 2012 6:56 AM
  • Hi Tom,

    Tried your code. Same behavior. Triggers once only. Please confirm that you have run the test on Outlook 2010 and the event is triggering more than once from an additional Mailbox store (not default store, not a pst store). Only an additional Mailbox of another user (shared Mailbox) is exhibiting the problem. Appreciate your feedback.

    Tuesday, March 20, 2012 7:44 AM
  • Hi 3ala2,

    I use Outlook 2010 on my side. And event works fine on my side. OK, I will involve some experts into this issue to see whether them aware of your issue. There might be some time delay, thanks for your patience.

    Have a good day,

    Tom


    Tom Xu [MSFT]
    MSDN Community Support | Feedback to us

    Wednesday, March 21, 2012 6:50 AM
    Moderator
  • Hi,

    Do you have the ReliableFolderMoveEvent registry key set on your Outlook 2010 machine? This is still required to enable the fixes to work correctly. The following article has the path for Outlook 2007, but you would need to change the path from 12.0 to 14.0:

    971367 The BeforeFolderMove or BeforeItemMove events are not called by a custom application after a while in Office Outlook 2007
    http://support.microsoft.com/default.aspx?scid=kb;EN-US;971367

    I also see this isn't mentioned in the following KB article, so I can get that updated to make it more clear:

    2265515 Known issues in Outlook 2010 when you use the object model
    http://support.microsoft.com/default.aspx?scid=kb;EN-US;2265515

    If you have that registry key set and it's still not working for you, I can see if I can reproduce this.

    Thanks!


    Bill Jacob - Microsoft Customer Service & Support - Developer Messaging

    Wednesday, March 21, 2012 7:25 PM
  • The registery key did not fix the problem. I tried to apply the December 2010 cumulative update but I got a message that the update is already installed. Still no solution.
    EDIT: I cannot find the update KB 2459115 (Outlook hotfix) or cumulative update KB 2479673 in the add remove programs windows updates. Is this normal? Please note that Outlook version has SP1 installed.
    • Edited by 3ala2 Wednesday, March 21, 2012 9:08 PM
    Wednesday, March 21, 2012 9:00 PM
  • OK, thanks for verifying that. The Dec. 2010 Cumulative Update is a part of SP1 already so you cannot install on top of SP1. I know it's a long shot, but can you also please try the latest Feb. 2012 update? You can get it here:

    2597137 Description of the Outlook 2010 hotfix package (x86 Outlook-x-none.msp, x64 Outlook-x-none.msp): February 28, 2012
    http://support.microsoft.com/default.aspx?scid=kb;EN-US;2597137

    This will get you the "latest and greatest" update for Outlook 2010.


    Bill Jacob - Microsoft Customer Service & Support - Developer Messaging

    Wednesday, March 21, 2012 9:07 PM
  • Just installed the february update. Still same problem :S.
    Wednesday, March 21, 2012 9:47 PM
  • Hi

    I know this is an old post but it looks not to be resolved and is an issue which I have suffered (greatly!!!) with as I have thought I've fixed it but it keeps rearing its ugly head.

    For me the issue is the same thing - the default account works fine but an additional one only works intermittently and will eventually fail but very inconsistent in how it works.

    I was wondering if anybody has had any luck with this or if Tom has consulted the experts.

    Thanks for any input

    Zak

    Wednesday, August 1, 2012 2:01 PM
  • No reply yet? Can anyone reproduce this problem?
    Tuesday, March 5, 2013 8:23 AM
  • Any news on this issue? Anyone?
    Tuesday, April 30, 2013 8:06 AM