Setting ActiveExplorer.CurrentFolder using C++

E

Eric

I'm using straight C++, working with IDispatch, from my COM add-in
DLL. All the samples I see for using the CurrentFolder property are
in VB or Delphi. I've translated enough of this code to figure out
what the related IDispatch::Invoke() calls should be.

However, I'm having trouble with this "CurrentFolder" property.
Whenever I try and set it, I must be corrupting something because
Outlook does strange things. Like changes the "Outlook Today" in the
folder list to read "Contacts", but selecting the folder in the list
still shows the "Outlook Today" page. I have to restart Outlook to
get the correct text to return.

I'll spare you all the very long C++ code, and just say that I'm doing
these steps:

1. Calling GetNameSpace method to get name space pointer.
2. Calling GetFolderFromID method to get IDispatch for folder I want
to view.
3. Calling ActiveExplorer method to get IDispatch for explorer.
4. Calling Invoke() method of explorer IDispatch to put/set the
"CurrentFolder" property to the IDispatch of the folder which was
returned from GetFolderFromID.

The first 3 steps are pretty basic, and I can verify that they work
correctly by calling the "Display" method on the returned folder or
explorer object. I've never used the CurrentFolder property before.
I'll say that it does feel weird having to pass a pointer to an
IDispatch (folder) interface in order to switch folders.

It seems like there should be a "SwitchFolders" method, or that the
"CurrentFolder" method should actually take the "Entry ID" of the
folder instead of the object. In the help files it does say that
CurrentFolder returns a MAPIFolder object though, which at the lower
level that amounts to an IDispatch pointer.

Can anyone imagine what I'm doing wrong, or does anyone have any code
which sets this property at the IDispatch level like I'm trying to do?
Or is there any way to do this using an IMessage (extended MAPI)
interface, which I'd much rather work with?
 
D

Dmitry Streblechenko \(MVP\)

Note that you must set the CurrentFolder property by ref, i.e. use
DISPATCH_PROPERTYPUT | DISPATCH_PROPERTYPUTREF | DISPATCH_METHOD
when calling IDispatch::Invoke().

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top