G
Guest
I have an Outlook 2003 using Exchange Server 2003 Public Contacts Folder containing 20,000 Contacts. I am writing a VB .Net 2003 program that loops through all the contacts in a "for each oCt in oItems" loop. After about 250 contacts, the program gives an InvalidCastException Error on the for each loop. I notice that Outlook's memory keeps increasing (using the task manager) until it reaches around 20,000K. When I run the program a second time (without closing Outlook), I then get the error after only 1 or 2 contacts. If I close Outlook and restart it, the program will run until about 250 contacts. Here is the code
Imports System.Reflectio
Imports Outlook = Microsoft.Office.Interop.Outloo
Module Module
Sub Main(
Dim i As Intege
Dim StrName As Strin
' Create Outlook application
Dim oApp As Outlook.Application = New Outlook.Applicatio
' Get namespace and Contacts folder reference
Dim oNS As Outlook.NameSpace = oApp.GetNamespace("MAPI"
Dim cContacts = oNS.Folders.Item("Public Folders").
Folders.Item("All Public Folders").
Folders.Item("Contacts"
Dim oItems As Outlook.Items = cContacts.Item
Dim oCt As Outlook.ContactIte
For each oCt in oItem
Console.Write(CType(i, String) + " "
oCt = oItems.GetNext(
StrName = CType(oCt.EntryID, String
Console.WriteLine(StrName
oCt = Nothin
Nex
oApp = Nothin
oItems = Nothin
End Su
End Modul
Anyone have any ideas on how to fix this? Right now we have 20,000 contacts in the public folder and the response time using Outlook to find a contact is about 1-2 seconds of search time. I have no problem with Outlook accessing all 20K contacts, only using VB .NET 2003. Any solution would be helpful.
Imports System.Reflectio
Imports Outlook = Microsoft.Office.Interop.Outloo
Module Module
Sub Main(
Dim i As Intege
Dim StrName As Strin
' Create Outlook application
Dim oApp As Outlook.Application = New Outlook.Applicatio
' Get namespace and Contacts folder reference
Dim oNS As Outlook.NameSpace = oApp.GetNamespace("MAPI"
Dim cContacts = oNS.Folders.Item("Public Folders").
Folders.Item("All Public Folders").
Folders.Item("Contacts"
Dim oItems As Outlook.Items = cContacts.Item
Dim oCt As Outlook.ContactIte
For each oCt in oItem
Console.Write(CType(i, String) + " "
oCt = oItems.GetNext(
StrName = CType(oCt.EntryID, String
Console.WriteLine(StrName
oCt = Nothin
Nex
oApp = Nothin
oItems = Nothin
End Su
End Modul
Anyone have any ideas on how to fix this? Right now we have 20,000 contacts in the public folder and the response time using Outlook to find a contact is about 1-2 seconds of search time. I have no problem with Outlook accessing all 20K contacts, only using VB .NET 2003. Any solution would be helpful.