G
Guest
I need to extract some data from custom items in a public folder and transfer
it to an Access database. The trouble is, after the first 249 items my code
can't open any more items. The trouble is definitely with the limit of 255
open RPC channels.
I understand the normal advice is to make sure all your objects are closed
in the reverse order they were opended, and to attempt to release the
channels between processing items. I have taken my code and stripped it down
to remove all the distractions, and this is what is left.
Sub Printx()
Dim objApp As Outlook.Application
Dim objExp As Explorer
Dim objFolder As Outlook.MAPIFolder
Dim colJobItems As Outlook.Items
Dim objJobItem As Outlook.PostItem
Dim x As Integer
Set objApp = CreateObject("Outlook.Application")
Set objExp = objApp.ActiveExplorer
Set objFolder = objExp.CurrentFolder
Set colJobItems = objFolder.Items
Set objJobItem = colJobItems.GetFirst
x = 1
Do While Not objJobItem Is Nothing
Debug.Print x 'To hold the place of my actual processing
x = x + 1
Set objJobItem = Nothing
Set objJobItem = colJobItems.GetNext
Loop
Set objJobItem = Nothing
Set colJobItems = Nothing
Set objFolder = Nothing
Set objExp = Nothing
Set objApp = Nothing
End Sub
I have also tried it without the Do While .. Loop, and called the whole
thing from a "For x = 0 to 300 ... Next" construction, but I still get the
same problem: 249 successful read/writes then it all packs up. Can anyone
suggest how I might make this work.
I really hope someone can give me some useful advice here.
Thanks inadvance
Vaughan
it to an Access database. The trouble is, after the first 249 items my code
can't open any more items. The trouble is definitely with the limit of 255
open RPC channels.
I understand the normal advice is to make sure all your objects are closed
in the reverse order they were opended, and to attempt to release the
channels between processing items. I have taken my code and stripped it down
to remove all the distractions, and this is what is left.
Sub Printx()
Dim objApp As Outlook.Application
Dim objExp As Explorer
Dim objFolder As Outlook.MAPIFolder
Dim colJobItems As Outlook.Items
Dim objJobItem As Outlook.PostItem
Dim x As Integer
Set objApp = CreateObject("Outlook.Application")
Set objExp = objApp.ActiveExplorer
Set objFolder = objExp.CurrentFolder
Set colJobItems = objFolder.Items
Set objJobItem = colJobItems.GetFirst
x = 1
Do While Not objJobItem Is Nothing
Debug.Print x 'To hold the place of my actual processing
x = x + 1
Set objJobItem = Nothing
Set objJobItem = colJobItems.GetNext
Loop
Set objJobItem = Nothing
Set colJobItems = Nothing
Set objFolder = Nothing
Set objExp = Nothing
Set objApp = Nothing
End Sub
I have also tried it without the Do While .. Loop, and called the whole
thing from a "For x = 0 to 300 ... Next" construction, but I still get the
same problem: 249 successful read/writes then it all packs up. Can anyone
suggest how I might make this work.
I really hope someone can give me some useful advice here.
Thanks inadvance
Vaughan