C
Chris
Hi,
I'm using Redemption's new RDO objects (4.0, very nice) and am having a
problem iterating through an sql table of contacts and converting them
into Exchange contacts. I am using RDOFolder.Items.Add and after
calling this about 260 times RDOFolder.Items.Add returns nothing. If I
keep a running total of the size of the contact items added the problem
occurs exactly when 32k of of total contacts have been added. I
imagine that a MAPITable is being used underneath but I don't know how
to reset or flush it in order to process more contacts. I've tried a
few things which you can see in the code below.
Cheers,
Chris
Here is the code snippet (vb.net):
For Each dr As DataRow In dt.Rows
With New MapiCodes
c = contactsFolder.Items.Add("IPM.Contact")
If c Is Nothing Then
MsgBox("c is nothing") ' This happens when
bufferSize reached 32000
End If
c.Fields(.CdoPR_TITLE) = dr("Title").ToString
c.Fields(.CdoPR_GIVEN_NAME) = dr("FirstName").ToString
c.Fields(.CdoPR_SURNAME) = dr("FamilyName").ToString
c.Fields(.CdoContact_EmailEmailAddress) =
dr("Email").ToString
c.Fields(.CdoPR_DISPLAY_NAME) =
dr("CalcFullNameInv").ToString
c.Fields(.CdoContact_FileUnder) = .CdoPR_DISPLAY_NAME
c.Fields(.CdoPR_COMPANY_NAME) =
dr("Institution").ToString
c.Fields(.CdoPR_BUSINESS_TELEPHONE_NUMBER) =
dr("Tel1").ToString
' c.Fields("urn:schemas:contacts:fileasid") = 32791
' c.Fields(.cdocontact
' .Add(CdoContact_FileUnderID, &HFFFFFFFF,
CdoPropSetID3)
c.Save()
bufferSize += c.Size
totalSize += c.Size
Debug.WriteLine(c.Size & "/" & bufferSize & "/" &
totalSize)
If bufferSize > 31000 Then
Debug.WriteLine("Now trying to reset")
' mapiUtils.Cleanup() ' Doesn't reset
contactsFolder = Nothing ' Doesn't reset
contactsFolder = GetFolderMapi(path,
publicRootFolder) ' Doesn't reset
bufferSize = 0
End If
End With
Next
mapiUtils.Cleanup()
I'm using Redemption's new RDO objects (4.0, very nice) and am having a
problem iterating through an sql table of contacts and converting them
into Exchange contacts. I am using RDOFolder.Items.Add and after
calling this about 260 times RDOFolder.Items.Add returns nothing. If I
keep a running total of the size of the contact items added the problem
occurs exactly when 32k of of total contacts have been added. I
imagine that a MAPITable is being used underneath but I don't know how
to reset or flush it in order to process more contacts. I've tried a
few things which you can see in the code below.
Cheers,
Chris
Here is the code snippet (vb.net):
For Each dr As DataRow In dt.Rows
With New MapiCodes
c = contactsFolder.Items.Add("IPM.Contact")
If c Is Nothing Then
MsgBox("c is nothing") ' This happens when
bufferSize reached 32000
End If
c.Fields(.CdoPR_TITLE) = dr("Title").ToString
c.Fields(.CdoPR_GIVEN_NAME) = dr("FirstName").ToString
c.Fields(.CdoPR_SURNAME) = dr("FamilyName").ToString
c.Fields(.CdoContact_EmailEmailAddress) =
dr("Email").ToString
c.Fields(.CdoPR_DISPLAY_NAME) =
dr("CalcFullNameInv").ToString
c.Fields(.CdoContact_FileUnder) = .CdoPR_DISPLAY_NAME
c.Fields(.CdoPR_COMPANY_NAME) =
dr("Institution").ToString
c.Fields(.CdoPR_BUSINESS_TELEPHONE_NUMBER) =
dr("Tel1").ToString
' c.Fields("urn:schemas:contacts:fileasid") = 32791
' c.Fields(.cdocontact
' .Add(CdoContact_FileUnderID, &HFFFFFFFF,
CdoPropSetID3)
c.Save()
bufferSize += c.Size
totalSize += c.Size
Debug.WriteLine(c.Size & "/" & bufferSize & "/" &
totalSize)
If bufferSize > 31000 Then
Debug.WriteLine("Now trying to reset")
' mapiUtils.Cleanup() ' Doesn't reset
contactsFolder = Nothing ' Doesn't reset
contactsFolder = GetFolderMapi(path,
publicRootFolder) ' Doesn't reset
bufferSize = 0
End If
End With
Next
mapiUtils.Cleanup()