Your server administrator has limited the number of items you can

S

spottedmahn

I'm iterating over some contacts in a public folder and I'm receiving the
follow error: "Your server administrator has limited the number of items you
can open simultaneously. Try closing messages you have opened or removing
attachments and images from unsent messages you are composing."

I've reviewed this forum thread but I can't find an answer :
http://social.technet.microsoft.com.../thread/4b2622bf-f55d-4b72-a30a-211f69e206a9/

How do I properly "release" the outlook com object?
 
S

spottedmahn

Hi JP, Sure thing.

Here is my current code. The code loops thru a public folder of contacts,
copies some of the contactItem.Properties into a Custom Object ContactItem so
I can display a grid of ContactItems:

public List<ContactItem> WcmsContactsWcmsObjects
{
get
{
List<ContactItem> Results = new List<ContactItem>();

//todo fix
//return Results;

Outlook.Items Contacts = this.WcmsContactsMapiFolder.Items;

Outlook.ContactItem Contact = (Outlook.ContactItem)
Contacts.GetFirst();

do
{
ContactItem NewCont =
ContactItem.FromOutlookContactItem(Contact, this.SifApp);

Results.Add(NewCont);

Contact = (Outlook.ContactItem)Contacts.GetNext();

} while (Contact != null);

return Results;

//int i = 1;

//foreach (Outlook.ContactItem Contact in
this.WcmsContactsOutlookObjects)
//{
// ContactItem NewCont =
ContactItem.FromOutlookContactItem(Contact, this.SifApp);

// Results.Add(NewCont);

// //Close Contact
// //Outlook._ContactItem As_ContactItem =
(Outlook._ContactItem) Contact;

//
//As_ContactItem.Close(Microsoft.Office.Interop.Outlook.OlInspectorClose.olDiscard);

// Marshal.ReleaseComObject(Contact);

// if (i > 50)
// {
// GC.Collect();
// GC.WaitForPendingFinalizers();
// GC.Collect();
// GC.WaitForPendingFinalizers();
// i = 0;
// }

// i++;
//}

return Results;
}

//Copy Outlook Data in to Custom Objects
internal static ContactItem
FromOutlookContactItem(Outlook.ContactItem Contact, FrsaSifApplication
SifAppIn)
{
ContactItem NewCont = new ContactItem();
NewCont.BusinessTelephoneNumber = Contact.BusinessTelephoneNumber;
NewCont.CompanyName = Contact.CompanyName;
NewCont.Email1Address = Contact.Email1Address;
NewCont.FileAs = Contact.FileAs;
NewCont.FirstName = Contact.FirstName;
NewCont.LastName = Contact.LastName;

if (Contact.UserProperties.Count > 0)
{
Outlook.UserProperty UserProp = Contact.UserProperties[1];

NewCont.PropertyName = UserProp.Name;
//unfortunately not support with sharepoint
if (UserProp.Type ==
Microsoft.Office.Interop.Outlook.OlUserPropertyType.olInteger)
{
NewCont.PropertyValueInt =
int.Parse(UserProp.Value.ToString());
}
else
{
SifAppIn.CommonObj.TraceThisShouldNotHappen("Unknown
Property Type", new StackFrame(true));
}

Marshal.ReleaseComObject(UserProp);

}
NewCont.EntryId = Contact.EntryID;
//NewCont.OutlookContactItem = Contact;
return NewCont;
}


The commented code was differnt attempt to "Close" the Contact


Thanks,
Mike D.
 
S

spottedmahn

Hi JP, thanks for the reply.

The link didn't really help me since I think the story changes a little when
dealing with Com Objects.


Thanks,
Mike D.
 

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