Dmitry,
After cleaning up the routine I use looks as the following:
protected void UserContacts(string LoginName)
{
Outlook._Application olApp =3D (Outlook._Application) new Outlook.Applicatio=
n();
Outlook.NameSpace mapiNS =3D olApp.GetNamespace("MAPI");
Outlook.Recipient oRecepient =3D mapiNS.CreateRecipient(LoginName);
oRecepient.Resolve();
if (oRecepient.Resolved)
{
Outlook.Folders myFolders;
Outlook.MAPIFolder myContFolder;
Outlook._ContactItem myContact;
myContFolder =3D mapiNS.GetSharedDefaultFolder(oRecepient,Outlook.OlDefau=
ltFolders.olFolderContacts);
myFolders =3D myContFolder.Folders;
myContFolder =3D myFolders.Item("CustomContacts"); //Custom Contacts folder
Outlook._Items myConts;
myConts =3D myContFolder.Items;
if (myConts.Count > 0)
{
myConts.Sort("[LastName]",0);
myContact =3D (Outlook._ContactItem)myConts.GetFirst();
do
{
Console.WriteLine(myContact.LastName + " " + myContact.FirstName);
myContact =3D (Outlook._ContactItem)myConts.GetNext();
}
while (myContact !=3D null);
}
myConts =3D null;
myContact =3D null;
myFolders =3D null;
myContFolder =3D null;
oRecepient =3D null;
mapiNS.Logoff();
mapiNS =3D null;
olApp =3D null;
}
}
The application goes through number of exchange users and theirs contacts. Number o=
f contacts per user is always less then 100. The application crashes after total numb=
er of processing contacts reaches 249. Using Marshal.ReleaseComObject doesn=E2=80=
=99t change a situation at all. But application works fine if I kill Outlook.exe proc=
ess after each user iteration or if counter of processed contacts reaches 248. =
The 250 contacts limitation issue looks legitimate according to the article: http:=
//support.microsoft.com/?kbid=3D830829. Is there any more elegant walk around t=
hen killing Outlook.exe process? Change registry settings and increase number of c=
ontacts from 250 to any larger number doesn=E2=80=99t look very nice as well. Thank y=
ou very much!