![]() |
If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Search this Thread | Display Modes |
#1
|
|||
|
|||
![]()
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.OlDefaultFo lders.olPublicFoldersAllP*ublicFolders).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(); } Thanks! leahann |
Ads |
#2
|
|||
|
|||
![]()
1. If you are using a for (1..Count) loop there is no reason to use
GetFirst/GetNext for(int i = 1; i = itemCount; i++) { item = items[i]; ContactItem cItem = item as ContactItem; 2. If you prefer to use GetFirst/GetNext, use a while loop. 3. Try to invoke GC.Collect() at each step of the loop (you can also try 50 or so steps instead) - Exchange has a limit of 255 RPC channels open at any given time, so you can easily run over teh limit, especially with .Net, which does not immediately release the COM objects. 4. Keep in mind that you can have distributions lists as well as contacts. Your code will fail if you hit a DistListItem object instead of ContactItem. Dmitry Streblechenko (MVP) http://www.dimastr.com/ OutlookSpy - Outlook, CDO and MAPI Developer Tool wrote in message ups.com... 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.OlDefaultFo lders.olPublicFoldersAllP*ublicFolders).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(); } Thanks! leahann |
#3
|
|||
|
|||
![]()
Well, isn't it always the simple thing that ends up being the solution?
I invoked the GC and it looks as though everything is coming back now. (Oh, and the for loop was a lazy leftover from several attempts at accessing the items in different ways, namely a direct assign.) Thanks for your help! leahann |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Null Contacts returned from MAPFolder.Items | [email protected] | Outlook - Using Contacts | 5 | May 15th 06 04:21 PM |
30 of 89 mailings are returned too many recipients? Why? | lexluther | Outlook - Using Contacts | 1 | April 4th 06 09:33 AM |
Please help with returned emails from new domain | JM | Outlook - General Queries | 7 | March 14th 06 04:06 PM |
Error report on returned mail. | Buiskop19 | Outlook Express | 13 | February 24th 06 01:26 PM |
Blank form returned | brianlowry | Outlook - Using Forms | 1 | January 11th 06 07:41 AM |