Check for empty Explorer.Selection causes error in Outlook Today

  • Thread starter Thread starter Slava Barouline
  • Start date Start date
S

Slava Barouline

Hi guys

I have an explorer toolbar in my Add-in and when user presses buttons on it,
Add-in does something to a selected mail item.

When I am in Outlook Today, it doesn't work - for unknown reason the check
Assigned(IExplorer.Selection) raises an exception.

IExplorer is not empty.

Why is it so?

Thanks
Slava
 
I have found an ugly hack

I check if I am in 'Outlook Today' folder:
IExplorer.CurrentFolder.Name <> FOutlookTodayFolder.Name

Strangely
IExplorer.CurrentFolder<> FOutlookTodayFolder
doesn't work for some reason

I get FOutlookTodayFolder like this:

NmSpace := OutlookApp.GetNamespace('MAPI');
Inbox := NmSpace.GetDefaultFolder(olFolderInbox);
FOutlookTodayFolder := Inbox.Parent as MAPIFolder;
 
Selection is probably empty because the OutlookToday folder is the top of
store and usually doesn't have items in it or anything selected.
 
You'd be better off comparing the entry ids rather than names.
The fact that (IExplorer.CurrentFolder<> FOutlookTodayFolder) is perfectly
normal. Each time you access Explorer.CurrentFolder, OOM returns a brand new
COM object.

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
 
In a normal folder Selection is never nil, even if it's empty

When I try to access IExplorer.Selection for Outlook Today, it's not empty -
I get an error
Probably Selection is invalid for Outlook Today
 
I will probably use EntryID if
(IExplorer.CurrentFolder<>FOutlookTodayFolder) will not work

It shows different addresses for IExplorer.CurrentFolder and
FOutlookTodayFolder
How can I compare them?
 
Because nothing prevents a user from creating a folder with the same name
somewhere else in the folder hierarchy. The folder name will be different in
a locale other than English.

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
 
a easier way to check it is:

int selected_items
try
{
selected_items = _Explorer.Selection.Count;
}
catch (COMException e)
{
return;
}


;-)

greetings
 
Back
Top