none
BeforeFolderMove Event - Get Source Folder RRS feed

  • Question

  • Hello to all out there,

    I've got a question concerning the BeforeFolderMove Event.

    Is there any possibility to get the folder object of the folder that is about to be moved to a new destination. To get the destination folder object is not the problem as it is part of the BeforeFolderMove signature.

    It would be great if somebody could support me on this issue.

    Kind regards,

    Fabian

    Monday, May 28, 2012 4:45 PM

Answers

  • You'd need to switch to a global wrapper collection of folder classes; each class should be specific to each folder.  When an event fires, it would then be for the folder related to the class.

    Eric Legault
    MVP (Outlook)
    About me...

    • Marked as answer by FabianLuft Monday, May 28, 2012 8:31 PM
    Monday, May 28, 2012 7:58 PM
    Moderator

All replies

  • You'd already have the folder that is being moved, as the BeforeFolderMove event only fires for the folder being moved.  That is, you have to get a reference to the folder in question that is being moved in order to catch the destination folder when the event fires.

    Eric Legault
    MVP (Outlook)
    About me...

    Monday, May 28, 2012 5:31 PM
    Moderator
  • Since you subscribe to the BeforeFolderMove event on a particular folder, it will be the soirce folder.

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

    Monday, May 28, 2012 5:31 PM
  • Ahh sorry,

    I forgot to mention that I registered this BeforeFolderMove Event for more than one folder. In order to avoid the garbage collection I stored all the folders in an array of Outlook.Folder[]. The keypoint I'm struggling with is to recognize which of the folders fired this event.

    Kind regards,

    Fabian

    Monday, May 28, 2012 7:45 PM
  • The same reasoning applies! Whatever folder is public to the class containing the event is the folder that's firing it!

    Eric Legault
    MVP (Outlook)
    About me...

    Monday, May 28, 2012 7:49 PM
    Moderator
  • Okay. I'm having the folder that fired the event within the array. But I need to get the correct folder object out of the array and as a result of this the name of the folder. The point is that i don't know how to get or even find the correct object within the array.
    • Edited by FabianLuft Monday, May 28, 2012 7:56 PM
    Monday, May 28, 2012 7:55 PM
  • You'd need to switch to a global wrapper collection of folder classes; each class should be specific to each folder.  When an event fires, it would then be for the folder related to the class.

    Eric Legault
    MVP (Outlook)
    About me...

    • Marked as answer by FabianLuft Monday, May 28, 2012 8:31 PM
    Monday, May 28, 2012 7:58 PM
    Moderator
  • Thanks a lot Eric,

    your solution worked for me and everything is running smoothly.

    Kind regards,

    Fabian

    Monday, May 28, 2012 8:31 PM
  • Hi Fabian,

    I'm not sure if I understood Eric's answer correctly. Can you please explain what did you do to get the source folder in BeforeFolderMove event?

    Best,

    Shujaat

    Thursday, October 25, 2012 8:10 AM
  • Eric suggested that the poster create a class that encapsulates the original Folder object and adds and handles the Folder.BeforeFolderMove() event and any other events related to the Folder. When the event fires it will fire only in that class, where there already is a Folder object representing the source folder.
     
    To keep the class instances alive they should be added to a list/dictionary/collection/something to keep them alive so they aren't garbage collected.
     
    That is simliar to how multiple Inspectors and Explorers are usualy handled, with wrapper classes.

    --
    Ken Slovak
    [MVP-Outlook]
    http://www.slovaktech.com
    Author: Professional Programming Outlook 2007
    "Syed Shujaat Hussain" <=?utf-8?B?U3llZCBTaHVqYWF0IEh1c3NhaW4=?=> wrote in message news:4c9d3537-b4e7-4cc5-85c9-ad1a4e30186b...

    Hi Fabian,

    I'm not sure if I understood Eric's answer correctly. Can you please explain what did you do to get the source folder in BeforeFolderMove event?

    Best,

    Shujaat


    Ken Slovak MVP - Outlook
    Thursday, October 25, 2012 2:59 PM