Re: Problem when Looping through large number on MS Exchange contacts

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



There is a limit of about 255 RPC channels, which in practice works out usually to around 249 or 250, that you are most likely running into. The problem mostly manifests itself when using the COM Interop and one of the ..NET languages. If that's the case for you the only thing you can do is set the objects to Nothing within your loop and if that doesn't work you'd have to release them using Marshall.ReleaseCOMObject and maybe also explicitly call the garbage collector in your loop, maybe at a 245 items count or something like that.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Absolute Beginner's Guide to Microsoft Office Outlook 2003
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm


"Carlos Lozano" <CarlosLozano@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message news:1E58CE93-4173-4095-9E1B-378B4F453B8C@xxxxxxxxxxxxxxxx
Hi,

My application loops through contact items located in a public folder.
Everything works fine until the selection brings a large number of contacts
(> 500).
The process stops with a "type mistmatch" error when the processed item
count reaches 250.


I have something like this:

dim oResults as Outlook.Results
dim oContact as Outlook.ContactItem
dim oObj as object
dim i as int32

' folder AdvancedSearch, retrieving contact items in a oSearch object,
' then assigning the result to the oResults object

for each oObj in oResults
i = i + 1
if oObj.MessageClass = "IPM.Contact" then ' To exclude distribution lists
set oContact = oObj
' Additional code goes here
end if
next


The error happens not always on same contact, but always near item 250 (What
a coincidence!!!)


If I break the the process adding the following inside the loop:
   if i = 248 then
       debug.assert(1 = 0) 'Breaks here
   end if

A lot of traffic happens between the client machine (Outlook) and the server
MS SBS2003 machine, after that I am able to resume the process, but will
eventually crash again if the processing a large enough to count another 250
iterations.


I will appreciate any help.

Carlos Lozano
CAX IT Services
www.caxonline.net

.



Relevant Pages

  • Re: Problem when Looping through large number on MS Exchange conta
    ... I am using VBA for this project. ... I tried setting the oObj and oContact to nothing before starting other ... > the objects to Nothing within your loop and if that doesn't work you'd have ... >> dim oContact as Outlook.ContactItem ...
    (microsoft.public.office.developer.outlook.vba)
  • Re: Problem when Looping through large number on MS Exchange conta
    ... each message explicitly and resetting it to Nothing inside the loop. ... OutlookSpy - Outlook, CDO ... >>> dim oResults as Outlook.Results ... >>> dim oContact as Outlook.ContactItem ...
    (microsoft.public.office.developer.outlook.vba)
  • Re: Looping through Query to create multiple sheets in excel- Just need the loop
    ... I always get to this point and I can't figure out how to loop through ... I have put the string in the query at the bottom. ... Optional strWorkSheet As String, Optional strRange As ... Dim objXLSheet As Object 'Excel.Worksheet ...
    (microsoft.public.access.forms)
  • Re: vbs to run thru list of files
    ... the plan for a script should contain the spots where to insert ... 04 Dim objFSO, objFl ... Dim oFile, sSIZ, ... ... What about variables used in a loop: ...
    (microsoft.public.scripting.vbscript)
  • Re: vbs to run thru list of files
    ... 04 Dim objFSO, objFl ... Dim oFile, sSIZ, ... ... What about variables used in a loop: ... b Index außerhalb des gültigen Bereichs ...
    (microsoft.public.scripting.vbscript)