none
BeforeItemMove event not fired in outlook when item deleted from remote machine RRS feed

  • Question

  • I am developing an outlook add-in, where I have events which will be fired when an item is deleted from drafts. So when I delete the files from my drafts on my machine, the `BeforeItemMove` event is fired.

    But here comes the interesting case. Additionally I also have a VM, where I have outlook installed and logged in to the same account. So my drafts are synced there as well. When I delete a draft on the VM, after some time the draft gets deleted on my system as well. But this time it doesn't fire the `BeforeItemMove` event. What am I missing? Is it even dependent on Exchange? Or is a new event for folder update that I should subscribe to? Below is my code.

           


    Microsoft.Office.Interop.Outlook.Folder draftsFolder = null;        
    draftsFolder = nameSpace.GetDefaultFolder(Microsoft.Office.Interop.Outlook.OlDefaultFolders.olFolderDrafts) as Microsoft.Office.Interop.Outlook.Folder; 
    draftsFolder.BeforeItemMove += new Microsoft.Office.Interop.Outlook.MAPIFolderEvents_12_BeforeItemMoveEventHandler(BeforeItemMoveFromDrafts);

    The event method is

       
    private void BeforeItemMoveFromDrafts(object Item, MAPIFolder MoveTo, ref bool Cancel)    
    {       
     ...        
    }

    PS. I also have a reference to the folder object, so that is not the issue.

    Monday, June 20, 2016 7:01 AM

Answers

  • Kiran,

    In my understanding the BeforeItemMove event shouldn't be fired on another machines. It is fired when an item is about to be moved or deleted from a folder, either as a result of user action or through program code. The code should be run against the local Outlook instance.

    P.S. Make sure that the source object is declared at the global scope to prevent it from swiping by the garbage collector.


    [custom.development]

    • Marked as answer by David_JunFeng Wednesday, June 29, 2016 9:56 AM
    Monday, June 20, 2016 10:52 AM

All replies

  • Kiran,

    In my understanding the BeforeItemMove event shouldn't be fired on another machines. It is fired when an item is about to be moved or deleted from a folder, either as a result of user action or through program code. The code should be run against the local Outlook instance.

    P.S. Make sure that the source object is declared at the global scope to prevent it from swiping by the garbage collector.


    [custom.development]

    • Marked as answer by David_JunFeng Wednesday, June 29, 2016 9:56 AM
    Monday, June 20, 2016 10:52 AM
  • Hi Kiran Kumnoor,

    According to your description, I have reproduced this issue, I aggree with Eugene's opinion. BeforeItemMove event fires when the item is about to be moved to another folder (including the Deleted Items folder) or when the item is about to be permanently deleted. It does not fire during auto-archiving or synchronizing operations.
    Tuesday, June 21, 2016 9:55 AM