OOM 2003: can't identify selected folder from Selection

K

Kelmen

Greeting, I'm working on add-in using C# and Outlook Object Model.

At one event I need to identify the selection items. But for case when
I selected a folder:
- the Selection.Count give me 1, ok.
- but getting the item out, I can't type cast it to MAPIfolder!
- I have no problem if the items are ContactItem!

Am I missing something, or its another OOM bug again?
 
S

SvenC

Hi,
At one event I need to identify the selection items. But for case when
I selected a folder:
- the Selection.Count give me 1, ok.
- but getting the item out, I can't type cast it to MAPIfolder!
- I have no problem if the items are ContactItem!

Am I missing something, or its another OOM bug again?

I do not think that the Selection collection will contain folder elements.
Whenever you select a folder you can see that the topmost element of that
folder is also selected. I guess that causes the count property to be 1 from
the beginning.
Depending on the view of the folder you might have no visual feedback that
one element of that folder is selected.

To get the folder of the selection you could use the Parent property of the
first element of the selection.
Try this in VBA:

Dim o As Object
Set o = ActiveExplorer.Selection.Item(1)
Debug.Print TypeName(o)
Debug.Print TypeName(o.Parent)

That should display an item type like MailItem, followed by MAPIFolder
 
K

Ken Slovak - [MVP - Outlook]

ActiveExplorer.CurrentFolder would also return the MAPIFolder that's
current.
 

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