Your server administrator has limited the number of items you can

Status
Not open for further replies.
S

spottedmahn

I'm receiving the following COMException:

"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."

when I try to iterate thru a list of Contact Items.

I've read a few posts on this same error message but I'm still unsure how of

how to properly fix it.

Here is my code:

List<ContactItem> Results = new List<ContactItem>();

Outlook.Items Contacts = this.WcmsContactsMapiFolder.Items;

Outlook.ContactItem Contact = (Outlook.ContactItem)

Contacts.GetFirst();

do

{

ContactItem NewCont =

ContactItem.FromOutlookContactItem(Contact, this.SifApp);

Results.Add(NewCont);

Marshal.ReleaseComObject(Contact);

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

} while (Contact != null);

return Results;

I've read posts that say you must call " Marshal.ReleaseComObject()" but

that doesn't appear to be closing the connection.

I've read posts that say to increase the simultaneous connection limit but

that doesn't see right to me. I'm able to view the contact list in Outlook

so it is reading it somehow.
 
Declare NewCont outside the loop so you aren't creating an instance of it

each pass through the loop. Set both contact objects to null, if that's not

enough to prevent the error then call Marshal.ReleaseComObject() on them. If

that's not enough then call the GC and WaitForPendingFinalizers(). Do it in

steps so you don't add more handling than the minimum needed. Using

ReleaseComObject() and the garbage collection is expensive.

"spottedmahn" <spottedmahn> wrote in message

news:E83373DD-3F20-4DC2-BECF-5F19C0952B15@microsoft.com...
> I'm receiving the following COMException:

> "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."

> when I try to iterate thru a list of Contact Items.

> I've read a few posts on this same error message but I'm still unsure how
> of
> how to properly fix it.

> Here is my code:

> List<ContactItem> Results = new List<ContactItem>();

> Outlook.Items Contacts = this.WcmsContactsMapiFolder.Items;

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

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

> Results.Add(NewCont);

> Marshal.ReleaseComObject(Contact);

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

> } while (Contact != null);

> return Results;

> I've read posts that say you must call " Marshal.ReleaseComObject()" but
> that doesn't appear to be closing the connection.

> I've read posts that say to increase the simultaneous connection limit but
> that doesn't see right to me. I'm able to view the contact list in
> Outlook
> so it is reading it somehow.

>
 
Re: Your server administrator has limited the number of items you

Hi Ken, thanks for the reply.

The point of the loop is to convert Outlook Contacts objects to My Custom

Contact Objects so it doesn't make sense to declare NewCont outside the loop.

Maybe I'm mis-understanding you?

I've seen similar suggestions in other forum posts and it seems like a cross

your fingers and hope solution which doesn't make me feel very comfortable.

It seems like there should be a reliable way of "closing" objects that you

open. Am I missing something?

Thanks,

Mike D.
wrote:


> Declare NewCont outside the loop so you aren't creating an instance of it
> each pass through the loop. Set both contact objects to null, if that's not
> enough to prevent the error then call Marshal.ReleaseComObject() on them. If
> that's not enough then call the GC and WaitForPendingFinalizers(). Do it in
> steps so you don't add more handling than the minimum needed. Using
> ReleaseComObject() and the garbage collection is expensive.

> >

>

>
 
Re: Your server administrator has limited the number of items you

Yes, if you don't follow the advice you've seen from me and other posters

you are missing something. If you follow the advice you won't have those

problems.

Declaring the NewCont object outside the loop creates only 1 of those

objects. You just set it and reset it inside the loop. If you declare it

inside the loop and the loop executes 200 times you just created 200 of

those objects.

You can still do what you want, and then have to use

Marshal.ReleaseComObject() on each object plus setting each object to null,

then calling GC and WaitForPendingFinalizers on each pass through the loop.

That will also work, but the performance of loop execution will suffer a

lot. What I recommended is a balance of getting the loop to work and having

it work as fast as possible.

"spottedmahn" <spottedmahn> wrote in message

news:5CED03A0-1FAC-4DA7-96BE-1DF681F606E9@microsoft.com...
> Hi Ken, thanks for the reply.

> The point of the loop is to convert Outlook Contacts objects to My Custom
> Contact Objects so it doesn't make sense to declare NewCont outside the
> loop.
> Maybe I'm mis-understanding you?

> I've seen similar suggestions in other forum posts and it seems like a
> cross
> your fingers and hope solution which doesn't make me feel very
> comfortable.

> It seems like there should be a reliable way of "closing" objects that you
> open. Am I missing something?

> Thanks,
> Mike D.
 
Re: Your server administrator has limited the number of items you

Hi Ken, thanks again for the reply.

I'm still not clear on your analysis of declaring NewCont outside the loop.

Whether I put NewCont inside or outside the loop N objects will be created.

The point of the loop is to take a Outlook Contact and create a Custom

Contact Object. Therefore for every Outlook Contact object there will be one

Custom Contact Object.

So if I have 200 Outlook Contacts in a MapiFolder the above code would

return a List<CustomContactObject> whose count is 200. Make sense?

As for setting each object to null I'm unclear on how that would effect

anything. With each iteration of the loop the variables are re-assigned to

other objects.

So on Pass 1 Contact = X, then on Pass 2 Contact = Y. Nothing points to X

anymore.

I'm not trying to be combative I'm just trying to understand.

Thanks for you input,

Mike D.
wrote:


> Yes, if you don't follow the advice you've seen from me and other posters
> you are missing something. If you follow the advice you won't have those
> problems.

> Declaring the NewCont object outside the loop creates only 1 of those
> objects. You just set it and reset it inside the loop. If you declare it
> inside the loop and the loop executes 200 times you just created 200 of
> those objects.

> You can still do what you want, and then have to use
> Marshal.ReleaseComObject() on each object plus setting each object to null,
> then calling GC and WaitForPendingFinalizers on each pass through the loop.
> That will also work, but the performance of loop execution will suffer a
> lot. What I recommended is a balance of getting the loop to work and having
> it work as fast as possible.

> >

>

>
 
Re: Your server administrator has limited the number of items you

If you declare an object outside the loop

Outlook.ContactItem NewCont = null;

and then instantiate instances of it within the loop you are only creating

one object. You are assigning an instance of that object each time through

the loop, then you set it to null/release. Next time through you are just

instantiating another instance of that object.

If you declare the object inside the loop you create one object each pass

through the loop, then instantiate it then release it.

Those 2 are not identical scenarios.

If you don't release the objects then they remain in memory until some

undetermined time in the future when the garbage collector finally runs

after the items go out of scope. The RPC channels remain committed until

those objects are released. Therefore you get the errors you described.

"spottedmahn" <spottedmahn> wrote in message

news:CF579691-286F-4DE1-970E-3FD81E1539E4@microsoft.com...
> Hi Ken, thanks again for the reply.

> I'm still not clear on your analysis of declaring NewCont outside the
> loop.
> Whether I put NewCont inside or outside the loop N objects will be
> created.

> The point of the loop is to take a Outlook Contact and create a Custom
> Contact Object. Therefore for every Outlook Contact object there will be
> one
> Custom Contact Object.

> So if I have 200 Outlook Contacts in a MapiFolder the above code would
> return a List<CustomContactObject> whose count is 200. Make sense?

> As for setting each object to null I'm unclear on how that would effect
> anything. With each iteration of the loop the variables are re-assigned
> to
> other objects.

> So on Pass 1 Contact = X, then on Pass 2 Contact = Y. Nothing points to X
> anymore.

> I'm not trying to be combative I'm just trying to understand.

> Thanks for you input,
> Mike D.
 
Status
Not open for further replies.
Similar threads
Thread starter Title Forum Replies Date
M The server is not available. Contact your administrator if this co BCM (Business Contact Manager) 1
D Delete Outlook emails from MS server Using Outlook 12
M Synchronization and backup of Outlook from local to server. Using Outlook 8
O How to find out the domain and server settings that my Outlook is using? Using Outlook 2
K Gmail not removed from server Using Outlook 3
N Trouble with server names Using Outlook 1
M Shift Delete doesn't delete email from server Using Outlook 3
M "Attachment Detacher for Outlook" add in, does it update the server copy of the email? Using Outlook 1
J Recover server side rules from OST/PST without access to the server Using Outlook 2
S client lost 3K contacts when office 365 for mac account deleted from company exchange server Using Outlook 5
CWM550 This rule has a condition that the server cannot process? Using Outlook 1
F Outlook 2019 Outlook 2019 Add and Sync to New computer Comcast server Using Outlook 2
HarvMan Outlook 365 loses "outlook.com" exchange server settings Using Outlook 1
B IMAP server rejects sent email - cannot deliver messages Using Outlook 2
L Help connecting to hosted exchange server 2016 Using Outlook 0
C Pop Server Changing Verizon/Aol to Yahoo Using Outlook 6
icacream Outlook 2016 “Enter your user name and password for the following server.” Using Outlook 5
R Outlook 365 update sets delete from server flag Using Outlook 1
J Importing N2K from a different Exchange Server Using Outlook 1
G Forward email body to other mail list directly from Exchange server Exchange Server Administration 1
T Outlook 2010 How to Delete “Orphaned” TO DO? ( Not on Exchange Server) Using Outlook 6
A Connect to server to views items Using Outlook 0
J Moved many emails to Outlook external folder, need to delete on Gmail server Using Outlook 14
icacream Enter your user name and password for the following server. Using Outlook 4
T How can Exchange be configured to sync/push one-way so that the server data can't be affected Exchange Server Administration 0
F outlook.com Exchane Server corrupts data Since September 2019 Using Outlook.com accounts in Outlook 6
llama_thumper Setting up forwarders on Exchange server Exchange Server Administration 0
W Encrypted connection to server refused Using Outlook 0
B Server errors Outlook 2007 Using Outlook 1
M Outlook 2016 Requesting data from server Using Outlook 0
R Copy Outlook Public Folders to a File Server Shared Folder Using Outlook 0
I IMAP - are emails dynamically fetched from server as required? Using Outlook 2
CWM030 Name Server's Exchange Server Administration 15
CWM030 Archiving ON the imap server Using Outlook 3
G How to have domain client use owa server instead of exchange server while connect to network Using Outlook 1
GaryW88 2016 Archiving IMAP keeping mail on Gmail Server Using Outlook 1
R Would creating a new profile cause Outlook to download all the old mails from the server? Using Outlook 1
P Microsoft Outlook is requesting data from the server Using Outlook 2
J Old unread emails on current date (MDaemon Server) Using Outlook 1
E Duplicate, nested account folders on ATT server Using Outlook 10
Cdub27 Your changes to this item couldn't be saved because Server Denied Operation (HTTP 403 Forbidden) Using Outlook 1
O Outlook 2016 0x800CCC0F 'The connection to the server was interrupted' Using Outlook.com accounts in Outlook 1
crazyboy Problems connecting to BCM on Server Using Outlook 2
M Problems Downloading Content from Server(s) Using Outlook 0
K IMAP Server Wants to alert you to the following: cannpt rename system folder Using Outlook 1
T Uploading Outlook 2016 Contacts to Exchange Server Drops "Company" field data in 30% of records Exchange Server Administration 4
Diane Poremsky Archiving Tools for Exchange Server Using Outlook 4
Diane Poremsky Changing the Message Size in Exchange Server Using Outlook 0
R Outlook 2007 - Shared Accounts and Resources without Exchange Server Using Outlook 0
J IMAP server Using Outlook 0

Similar threads

Back
Top