ActiveExplorer.Selection exception / working with currently selecded items

G

Greg Vasilyev

Hello everyone:



I am trying to create an Outlook Add-in that will pick all selected contact
items in a currently visible folder and will create a broadcast fax message
using information saved with each contact item.



I was originally trying to perform this using VBA macro. It crashed and I
tried to make an add-in (for better stability) that currently gives me the
same error message.



When I do colSelectedItems = oApplication.ActiveExplorer.Selection, Outlook
starts to pull each selected contact's data into Selection collection. It
does it for about 30sec (memory used by application increases) and then it
throws an exception "The messaging interface has returned an unknown error.
If the problem persists, restart Outlook" and the memory usage drops down.



The same code works just fine when I select about 200 items. When I select
something more than 300, it throws the exception.



The contacts in a folder have a customized form set up. Tried with the same
result on Outlook 2000 - 2003 and MS Exchange 2003 on the back-end.



Any help is greatly appreciated.



Sincerely,

Greg Vasilyev
 
G

Greg Vasilyev

Hi,
I narrowed the code to keep the main idea only (VBA macro version):

Set oOutlookExplorer = Application.ActiveExplorer
Set colSelectedItems = oOutlookExplorer.Selection
If colSelectedItems.Count > 0 Then
For i = 0 To colSelectedItems.Count
Set oMyItem = colSelectedItems.Item(i)
'do the rest of processing here
Set oMyItem = Nothing
Next 'i
End If 'colSelectedItems.Count > 0

the code fails at Set colSelectedItems = oOutlookExplorer.Selection
and it does it only when I select more than about 300 contacts

Thanks in advance,
Greg
 
D

Dmitry Streblechenko \(MVP\)

There is nothing you can do - touching the Selection collection causes
Outlook to load each selected item and exceed the max number of available
RPC channels (255/process).
The problem has been fixed in Outlook 2003.

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

Greg Vasilyev

Thank you, Dmitry

Unfortunately, it doesn't look like it was fixed in 2003 - the exception is
not being thrown, however when you start looping through the items in a
collection, whatever is over count of 255 (or close to that) throws another
exception (it says something like it cannot access properties of the contact
item).

There is a software called "Outlook Aladdins" from Manawatu software
solutions. They pull all the selected contacts and create envelopes from
that data. So, they clearly interface somehow with outlook to get "what has
been selected".
I have tested them with thousands of selected items and the software did not
fail - the memory didn't increase either; and the software instantly showed
how many items were selected...

So, do you know of any other way to reference selected in Outlook items?

Thank you in advance,
Greg
 
D

Dmitry Streblechenko \(MVP\)

As you loop through selection in Outlook 2003, do you release the items that
you are done with? Note that 255 RPC channels/process limit is still there.
In case of .Net languages, make sure you force the the COM object release,
simply setting it to nothing is not enough.

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

Greg Vasilyev

That I haven't tried.

Unfortunately the primary install base for my thing will be Outlook 2000, so
even if Ol2003 works fine, it will not be an optimal solution for me.

Dmitry, do you know about any other way to get reference to outlook
selection that will be similar to referencing the Explorer.Selection
collection? The one that would work with Ol2K?

Thank you in advance,
Greg
 

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