Hi Ken,
Thanks for the reply.
But which event do i need to handle for subscribing folderadd event? now I'm
subscribing folders.folderadd in the below events:
this.m_activeExplorer =
(Outlook11.Explorer)this.applicationObject.ActiveExplorer();
if (this.m_activeExplorer != null)//subscribe folder switch
event handler
{
this.m_currentFolderCollection =
(Outlook11.Folders)this.m_activeExplorer.CurrentFolder.Folders;
if (this.m_currentFolderCollection != null)
{
this.m_currentFolderCollection.FolderAdd +=new
Microsoft.Office.Interop.Outlook.FoldersEvents_FolderAddEventHandler(m_currentFolderCollection_FolderAdd);
}
//folder switch
this.m_activeExplorer.FolderSwitch += new
Outlook11.ExplorerEvents_10_FolderSwitchEventHandler(exp_FolderSwitch);
}
private void exp_FolderSwitch()
{
//get current active explorer
if (this.m_activeExplorer != null)
{
//if any previously selected folder exists
if(this.m_currentFolderCollection != null)
this.m_currentFolderCollection.FolderAdd -= new
Microsoft.Office.Interop.Outlook.FoldersEvents_FolderAddEventHandler(m_currentFolderCollection_FolderAdd);
this.m_currentFolderCollection =
(Outlook11.Folders)this.m_activeExplorer.CurrentFolder.Folders;
if (this.m_currentFolderCollection != null)
{
this.m_currentFolderCollection.FolderAdd += new
Microsoft.Office.Interop.Outlook.FoldersEvents_FolderAddEventHandler(m_currentFolderCollection_FolderAdd);
}
But I'm facing issues in Outlook 2007. In outlook 2007, user can right click
without selecting a node in tree view. So I will not get the correct folder.
Also the new folder can be changed using PickFolder dialog displayed while
specifying a new folder name.
Which event handler do I need to use for subscribing Folders.FolderAdd event?
Thanks
"Ken Slovak - [MVP - Outlook]" wrote:
> NameSpace.Folders will be a collection of all the stores you have open (PST
> files, Exchange maiboxes and Exchange public folders). Add a new store and
> NameSpace.Folders.FolderAdd will fire.
>
> Assuming you have only 1 store open, say a PST file, then to get a new
> folder added at the top level just under Personal Folders you'd use this:
>
> NameSpace.Folders.Item(1).Folders.FolderAdd
>
> That would only handle adding a top level folder.
>
> To get a new folder added under Inbox (as an example) you have to get Inbox
> and its Folders collection and subscribe to FolderAdd for that collection.
> Another handler would have to handle FolderAdd for subfolders of Calendar,
> etc.
>
> FolderAdd will only fire for that specific Folders collection, not any
> Folders collection anywhere. So to do exactly what you want you'd need to
> instantiate an object for every existing folder in the store and handle the
> FolderAdd event for every one of those folder's Folders collection. It can't
> be handled with just one universal event handler.
>
> --
> Ken Slovak
> [MVP - Outlook]
> http://www.slovaktech.com
> Author: Professional Programming Outlook 2007.
> Reminder Manager, Extended Reminders, Attachment Options.
> http://www.slovaktech.com/products.htm
>
>
> "WLAN" <(E-Mail Removed)> wrote in message
> news
C29D19F-6F11-4024-BCAC-(E-Mail Removed)...
> >I want to handle folder add event in the following cases:
> >
> > User can create folder under any root folder, sub folder or sub sub
> > folders.
> > So if subscribe namespace.folders.folderadd, Will it trigger for sub
> > folder
> > or sub sub folder of that collection.
> >
> > How do I handle this situation?
> >
> > I need to handle folderadd event when user says 'New Folder'. The new
> > folder
> > can be under root folder or can be under Inbox or can under Drafts or can
> > be
> > under Inbox\MyMails.
>
>