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?
SvenC - 24 Jul 2007 08:48 GMT
Hi,
> At one event I need to identify the selection items. But for case when
> I selected a folder:
[quoted text clipped - 3 lines]
>
> 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
--
SvenC
Ken Slovak - [MVP - Outlook] - 24 Jul 2007 14:27 GMT
ActiveExplorer.CurrentFolder would also return the MAPIFolder that's
current.

Signature
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
> Hi,
>
[quoted text clipped - 26 lines]
> --
> SvenC