Outlook 2k3 Script: Pb extracting list of items

  • Thread starter news.microsoft.com
  • Start date
N

news.microsoft.com

Hi all

I want to exctract from a specific folder items that math my request but my
outlook hang

if companies = "my wated companies" than put the object in body mail

myfolder contain over 9000 task

here is may code

Sub CommandButtonS1_click
Set myItem2 = Application.CreateItem(0)
Set Rep2Base = Application.GetNamespace("MAPI").Folders("publics
folders").Folders("all public folders").Folders("myfolder")
MyIndex=0
total=Rep2Base.items.count
do while myindex < Total
MonIndex=MonIndex+1
Set myItem = Rep2Base.Items(MonIndex)
if MyItem.companies = "CompaniesABC" then
MyItem2.body = MyItem2.body & chr(13)
MyItem2.body = MyItem2.body & myItem.companies & ";" & myItem.mileage &
";" & myItem.Subject & ";" & myItem.UserProperties("Custom1") & ";" &
myItem.UserProperties("Custom2") & ";" & myItem.UserProperties("Custom3")
end if
loop
MyItem2.display
end sub


Tks
 
K

Ken Slovak - [MVP - Outlook]

Does it work if you access fewer items at a time in the loop? Try calling
the loop with a counter variable that does 100 items at a time and then
calling it again until all the items in the folder are processed.
 
K

Ken Slovak - [MVP - Outlook]

You're either running into memory leaks or more likely the 256 RPC channel
limit. The only way around that is to reduce your loop size and call the
loop code repeatedly from another procedure. Otherwise the internal object
variables created in the loop won't get released and you'll have the same
problem. When the loop procedure ends the objects are released so you need
to call the loop repeatedly.
 
N

news.microsoft.com

Okay

I'll try that

Tks


Ken Slovak - said:
You're either running into memory leaks or more likely the 256 RPC channel
limit. The only way around that is to reduce your loop size and call the
loop code repeatedly from another procedure. Otherwise the internal object
variables created in the loop won't get released and you'll have the same
problem. When the loop procedure ends the objects are released so you need
to call the loop repeatedly.
 

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