Re: Problem when Looping through large number on MS Exchange conta
- From: "Dmitry Streblechenko" <dmitry@xxxxxxxxxxx>
- Date: Wed, 15 Jun 2005 11:35:41 -0700
It has to do with how VB Scrpt engine is releasing implicit COM objects.
Instead of using the "for each" loop, use a "for i= 1 to..." loop retrieving
each message explicitly and resetting it to Nothing inside the loop.
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
"Carlos Lozano" <CarlosLozano@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:481D447B-7161-459A-96DA-C7F7E02CFE36@xxxxxxxxxxxxxxxx
> Hi Ken,
>
> I appreciate your help.
>
> I am using VBA for this project. Do you know How I can release resources
> using VBA?
>
> I tried setting the oObj and oContact to nothing before starting other
> cycle, but did not help.
>
> It is like the client computer is retrieving objects from the buffer or
> pipe
> faster than the server adding new ones. If the process is in break mode,
> the
> buffer is filled again and it can resume.
> Other option would be to pause the process every 100 iterations (sleep). I
> know that is possible in .NET. Do you know if it is possible in VBA?
>
> Thank you,
>
> Carlos Lozano
>
> "Ken Slovak - [MVP - Outlook]" wrote:
>
>> 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
>>
>>
.
- Follow-Ups:
- Re: Problem when Looping through large number on MS Exchange conta
- From: Carlos Lozano
- Re: Problem when Looping through large number on MS Exchange conta
- References:
- Problem when Looping through large number on MS Exchange contacts
- From: Carlos Lozano
- Re: Problem when Looping through large number on MS Exchange contacts
- From: Ken Slovak - [MVP - Outlook]
- Re: Problem when Looping through large number on MS Exchange conta
- From: Carlos Lozano
- Problem when Looping through large number on MS Exchange contacts
- Prev by Date: Re: Choosing items in inbox from vb app
- Next by Date: Re: Choosing items in inbox from vb app
- Previous by thread: Re: Problem when Looping through large number on MS Exchange conta
- Next by thread: Re: Problem when Looping through large number on MS Exchange conta
- Index(es):
Relevant Pages
|