Outlook 2003 pia's with .Net

J

Jess

Hi,

I am trying to populate an exchange public folder with contacts, but I keep
getting COMExceptions ("The operation failed") after the 250th contact is
added. I have tried pausing the thread or waiting for the item added event to
fire, but still the exceptions keep flowing.

I have full access to the computer and the exchange server folder, and the
folder can hold more than 250 contacts if they are added manually.

The code I am using is:

Private Sub DoOutlookStuff()
Dim OutlookApp As Outlook.Application
Dim ns As Outlook.NameSpace
Const Folder As String = "GEMSContacts"
Const Server As String = "Server01"
Dim Coll As Outlook.Items
Dim fldr As Outlook.MAPIFolder
Dim a As Integer
'start outlook
Try
OutlookApp = New Outlook.Application
ns = OutlookApp.GetNamespace("Mapi")
Dim tempfldr As Outlook.MAPIFolder =
ns.GetDefaultFolder(Outlook.OlDefaultFolders.olPublicFoldersAllPublicFolders)
fldr = tempfldr.Folders(Folder)
Coll = fldr.Items
Catch ex As Runtime.InteropServices.COMException
Stop
End Try
'delete all current contacts
While Coll.Count > 0
Try
Coll(Coll.Count).delete()
a += 1
Catch ex As Runtime.InteropServices.COMException
Stop
End Try
End While
Stop
'add contacts
Dim cn As Outlook.ContactItem
For a = 1 To 255
Try
cn = fldr.Items.Add
cn.FirstName = "Firstname"
cn.MiddleName = "Middlename"
cn.LastName = "Surname"
cn.Save()
Catch ex As Runtime.InteropServices.COMException
Stop 'this errors after 250 contacts are added
End Try
Next
End Sub

Any pointers as to why this is happening would be greatly appreciated.

Jess
 
N

Nico De Greef

Hi,

I have a similar problem with the 'Outlook becomes unstable after
reading...' post.
You have probably Exchange 2003 server who stops the session after a certain
amount of open objects. Your Exchange Server will probably log a 'too many
session' error at the same time of the application error.

I have no solution or decent workaround found yet, if you do please let me
know.

You could increase the total open objects treshold of the exchange server,
but this seems to risky to me and does not solve the problem.
 

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