Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Outlook / Contacts / May 2006

Tip: Looking for answers? Try searching our database.

Null Contacts returned from MAPFolder.Items

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
leahann@gmail.com - 11 May 2006 21:49 GMT
I'm new to OL programming, am using C#, and am having an issue...

We have a Public Folder that contains a Contacts form with
approximately 5,000 contacts.  We want to export this to an Excel
report programmatically.

Using Outlook.MAPIFolder.Folders[MY_FOLDER].Items.Count shows the
correct number of items, but when looping through these items after
about 2,000 they all end up being null.  I've found a few topics on
this problem, but none seem to address the problem I'm having.

Is there a limit to the number of Items that can be returned from the
folder?  Does anyone know a solution for this?  ANY help would be
greatly appreciated!!!

My code:

           Outlook.MAPIFolder aFolder =
mapiNamespace.GetDefaultFolder(Outlook.OlDefaultFolders.olPublicFoldersAllPublicFolders).Folders["My
Folder"]

           Items items = aFolder.Items;

           int itemCount = items.Count;
           object item = items.GetFirst();

           for(int i = 0; i < itemCount; i++)
           {
               ContactItem cItem = item as ContactItem;

               if (cItem != null)
               {
                   itemInfo[0] = cItem.LastName;
                   itemInfo[1] = cItem.FirstName;
                   itemInfo[2] = cItem.CompanyName;
                   ...
               }

               allItems.Add(itemInfo);
               itemInfo = new String[9];

               item = items.GetNext();
           }
Ken Slovak - [MVP - Outlook] - 12 May 2006 14:16 GMT
I'm not sure this is it, but I vaguely recall a problem with the Getxxx
constructs. See if using a direct assignment works:  item = items[i]

Signature

Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Absolute Beginner's Guide to Microsoft Office Outlook 2003
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm

> I'm new to OL programming, am using C#, and am having an issue...
>
[quoted text clipped - 39 lines]
>                item = items.GetNext();
>            }
leahann@gmail.com - 12 May 2006 16:39 GMT
Yeah, I tried that already.  It's actually the first way I tried to
access the items.  When I kept receiving the null values, I thought
maybe the direct assignment was the problem, so I switched to looping
through with the GetNext() method.
Ken Slovak - [MVP - Outlook] - 12 May 2006 19:58 GMT
No idea then. It's not the famous 250 limit where you're limited to about
250 or so RPC channels, that would hit you much faster.

Signature

Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Absolute Beginner's Guide to Microsoft Office Outlook 2003
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm

> Yeah, I tried that already.  It's actually the first way I tried to
> access the items.  When I kept receiving the null values, I thought
> maybe the direct assignment was the problem, so I switched to looping
> through with the GetNext() method.
leahann@gmail.com - 12 May 2006 20:46 GMT
Hi Ken,

Thanks for you help.  I think it actually was the 255 RPC channel
limit.  Someone recommended invoking the GC, which seemed to do the
trick.  I'm not sure why I was getting back several thousand items
before this limit hit its threshold, though.  But, then again, GC seems
to be a bit fickle anyway, so it's not surprising.

Thanks!

Leah Ann
Alexa - 15 May 2006 16:21 GMT
Yes, I got the same problem when I was doing the same thing. I solved it by
sleeping the thread for every 5 contacts or so and then call the GC to clean
up the memory residue.

Alexa

> Hi Ken,
>
[quoted text clipped - 7 lines]
>
> Leah Ann
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.