Restrict method problem

D

Dmitry Streblechenko

What is your code and did you make sure you release all the COM objects
using Marshal.ReleaseCOMObject?

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
 
M

Mike Epp

Dmitry. I am using C# (vs.net 2003) and have exactly the same 249 contacts
limitation issue reading through outlook contacts folder. I tried to release
all outlook objects using Marshal.ReleaseComObject as you adviced. But there
is no luck. I hope that at this time you may have a solution already. Could
you please help? Thank you in advance.
 
M

Mike Epp

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!
 

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