Programmatically adding contacts to a folder causes PST to grow exponentially

T

Tim

I have a custom contact folder that also has contact subfolders. I've
installed a custom contact form and made it the default for these contact
folders. The problem I'm seeing is that when I programmatically add about
450 contacts to 4 of those contact folders that the size of the PST file
grows to about 20 MB in size. Why is this happening?



This is especially puzzling since if I take those contacts and just copy the
450 contacts into 4 of those contact folders manually through the Outlook
interface, the size of the PST ends up being only about 3.5 MB. Those
contacts I copy in are using the same custom contact form as when I add them
programmatically and if I look at the size of the contacts they are the same
size as the ones I copied manually.



Initiating the Compact Now does shrink the size of the PST from 20 MB to 7
MB. Is there any way to initiate this command programmatically?



One further question when deleting contacts from a folder is it possible to
stop them from going to the deleted items folder?



Thanks

Tim
 
S

Sue Mosher [MVP-Outlook]

Show the code you're using to copy the contacts. What's the average size of
one of the contact items using a custom form?

Outlook provides no way to compact a .pst file programmatically.
 
S

Sue Mosher [MVP-Outlook]

Either use CDO to perform the deletion or move the item to the Deleted Items
folder, then delete the moved item.
 
T

Tim

The average size of the contacts are about 2 KB with each folder being about
861 KB which works out to be about what it was when I copied the contacts
through the Outlook interface. To me it appears the process of saving the
contact causes a lot of internal work to be done inside the PST which causes
the growth although I don't know what that would be and why its any
different than creating then through the interface.

In the code I'm not copying the contacts but retrieving them from a customer
SharePoint list and saving them separately into each contact subfolder based
on a custom keywords list field. I found that sorting the contacts by a
custom keywords list field and them copying them actually took longer (at
least the way I coded) than using this approach. Nevertheless the size of
the PST file increased in both ways.

This is the basis of the code although I've stripped out all the contact
fields to make it readable.
For intRow = 0 To myRowsMod.GetUpperBound(0)

oContact = oFolder.Items.Add

With oContact

'Parse items from SharePoint and add them to the appropriate
Contact fields

End Select

'Finally, save the ContactItem

.Save()

End With

Next
 
S

Sue Mosher [MVP-Outlook]

I don't know why the PST might be growing like that but, frankly, it doesn't
sound like a real problem since the background compacting will eventually
shrink it when the machine is idle.

--
Sue Mosher, Outlook MVP
Author of
Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 

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