Help!

OOM 2003: can't identify selected folder from Selection


Post new topic   General Reply to Topic (not reply to a specific post)    Forums Home -> Program Add-Ins RSS
Next:  I can't receive mail for my other profile in Outl..  
Author Message
Kelmen
External


Since: Jul 24, 2007
Posts: 1



PostPosted: Tue Jul 24, 2007 12:16 am    Post subject: OOM 2003: can't identify selected folder from Selection
Archived from groups: microsoft>public>outlook>program_addins (more info?)

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?
Back to top
SvenC
External


Since: Jun 27, 2007
Posts: 10



PostPosted: Tue Jul 24, 2007 9:48 am    Post subject: Re: OOM 2003: can't identify selected folder from Selection [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

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

--
SvenC
Back to top
Ken Slovak - [MVP - Outlo
External


Since: Oct 17, 2003
Posts: 3213



PostPosted: Tue Jul 24, 2007 9:48 am    Post subject: Re: OOM 2003: can't identify selected folder from Selection [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

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

--
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


"SvenC" <SvenC DeleteThis @community.nospam> wrote in message
news:1E3BF478-B3D0-4202-95BB-AE5A5C9C75D4@microsoft.com...
> 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
>
> --
> SvenC
Back to top
Display posts from previous:   
Post new topic   General Reply to Topic (not reply to a specific post)    Forums Home -> Program Add-Ins All times are: Eastern Time (US & Canada) (change)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum