Collector? You know the Solution?
The program in the test's case, whit 350 contacts, run OK before number
86. The error is a "Array index out of bounds".
Microsoft.Offic e.Interop.Outlo ok._Application olApp = new
Microsoft.Offic e.Interop.Outlo ok.ApplicationC lass();
Microsoft.Offic e.Interop.Outlo ok._NameSpace olNs =
olApp.GetNamesp ace("MAPI");
Microsoft.Offic e.Interop.Outlo ok.MAPIFolder aContacts =
olNs.GetDefault Folder(Microsof t.Office.Intero p.Outlook.OlDef aultFolders.olF olderContacts);
Microsoft.Offic e.Interop.Outlo ok.Items oItems = aContacts.Items ;
FAddressBookNam e = aContacts.Addre ssBookName;
foreach (Microsoft.Offi ce.Interop.Outl ook._ContactIte m oContact in
oItems)
{
//do something
}
"JC" <jc***@macomexp ress.comwrote in message
news:uX******** ******@TK2MSFTN GP02.phx.gbl...
Hi...
Anybody knows what problem has this code? I think, in the Garbage
Collector? You know the Solution?
The program in the test's case, whit 350 contacts, run OK before number
86. The error is a "Array index out of bounds".
Microsoft.Offic e.Interop.Outlo ok._Application olApp = new
Microsoft.Offic e.Interop.Outlo ok.ApplicationC lass();
Microsoft.Offic e.Interop.Outlo ok._NameSpace olNs =
olApp.GetNamesp ace("MAPI");
Microsoft.Offic e.Interop.Outlo ok._Folders oFolders =
olNs.Folders;
Microsoft.Offic e.Interop.Outlo ok.MAPIFolder aContacts =
olNs.PickFolder ();
Microsoft.Offic e.Interop.Outlo ok.Items oItems =
aContacts.Items ;
for (int i = 0; i <= x; oItems.Count)
{ //Explota en la proxima linea.
Microsoft.Offic e.Interop.Outlo ok._ContactItem oContact =
(Microsoft.Offi ce.Interop.Outl ook._ContactIte m)oItems[i];
//Do something with oContact
oContact = null;
}
In this second case, the error appear in the line before the "for".
Microsoft.Offic e.Interop.Outlo ok._Application olApp = new
Microsoft.Offic e.Interop.Outlo ok.ApplicationC lass();
Microsoft.Offic e.Interop.Outlo ok._NameSpace olNs =
olApp.GetNamesp ace("MAPI");
Microsoft.Offic e.Interop.Outlo ok._Folders oFolders =
olNs.Folders;
Microsoft.Offic e.Interop.Outlo ok.MAPIFolder aContacts =
olNs.PickFolder ();
Microsoft.Offic e.Interop.Outlo ok.Items oItems =
aContacts.Items ;
int x = oItems.Count;
//Explota en la proxima linea.
for (int i = 0; i <= x; i++)
{
Microsoft.Offic e.Interop.Outlo ok._ContactItem oContact =
(Microsoft.Offi ce.Interop.Outl ook._ContactIte m)oItems[i];
//Do something with oContact
oContact = null;
}