The following code cruises through the first few hundred records, but then hits a snails pace. Does anyone know why this may be or how it might be optimized for better performance (btw: this is running on a good processor w/ 2 gig RAM)

Outlook.MAPIFolder contacts =
MAPIFolder businessContacts =
contacts.Folders["Existing Business Contacts"];
ContactItem contact;

SalesContactsTableAdapter ta = new SalesContactsTableAdapter();
SalesContactsDataSet ds = new SalesContactsDataSet

foreach (SalesContactsDataSet.SalesContactsRow row in ds.SalesContacts)
contact =
contact.CustomerID = row.ContactId.ToString();
contact.Title = row.Title1;
contact.FirstName = row.FirstName1;
contact.LastName = row.LastName1;
contact.Suffix = row.Suffix1;
contact.JobTitle = row.PositionHeld1;
contact.Email1Address = row.Email1;
contact.CompanyName = row.CompanyName;


Cheers ~ jp

Re: Visual Studio Tools for Office Bulk Item Creation and Performance (or lack of...)

Phil Hoff - MSFT

I see similar behavior on my machine after a thousand items or so. After some experimentation, I was able to keep a flat item creation rate (at least through 5000 items) by forcing a garbage collection every 100 items. You might try something similar. For example:

int i = 0;

foreach (...row in dataset...)


// Add item


if (i % 100 == 0)





It may be that you're creating items (which are really just wrapped COM objects) far faster than the GC is freeing them and the management overhead accumulates to the point where it impacts the creation of new items. On the other hand, I'm not a CLR expert so you might get a more accurate answer on a CLR-specific forum.