Sorry it's taken me so long to get back. Yes, this is a server side app.
What took so long is that I was trying to pare down the code and see if I could spot where the problem is. I am currently importing 39 fields of information. When I reduced the number of fields, I was able to import more records.
Because the program has to run on a separate computer that has Exchange and not the one where I have my development tools, it's hard to find where the break occurs. (The only way I know is to put in msgbox lines and watch it cycle--any other debugging tips?)
Below is the code from the main module.
Any help is greatly appreciated.
---
Option Explicit
Public arrsubstring() As String
Public sURL As String
Public bFound As Boolean
Public strFolder As String
Public txtFile
Public oPer
Public bFlagImportOnly As Boolean 'flag from Form1 to import only
'modified gbren 10/6/03
'** Error constants used in this module
Private Const ERR_CONTACT_NOT_FOUND As Long = &H80040E19
'This module is designed to take a CSV file, read a line, separate into an array,
'then check to see if the value exists in an Exchange folder. If it does, it modifies
'the fields, if it does not, it adds it.
'4-14-03 Change made to import into a folder using DSM number
Sub PopulateArray2()
'when csv, will need to open file
Dim fs, f, ts, s
Dim sFileName As String
Dim x As Integer
Dim blnErrFlag As Boolean
Dim strLogFileName As String
Dim objEmail As CDO.Message
Dim blnAddOnlyFlag As Boolean
Dim flag As String
Dim adoConn As ADODB.Connection
Dim sStartingURL As String
On Error Resume Next
sFileName = "C:\vbs\outlook.CSV" 'starting filename for CSV file location
sStartingURL = "file://./backofficestorage/test.com/public folders/DealerBooks/"
'On Error GoTo Escape
sFileName = InputBox("Where is the CSV file?", "Populate Array", sFileName)
'Open the Text file
Set fs = CreateObject("Scripting.FileSystemObject"

Set f = fs.GetFile(sFileName)
Set ts = f.OpenAsTextStream(1, -2) '(ForReading, TristateUseDefault)
'Initialize Log File
strLogFileName = "C:\VBS\ImportLog-" & Year(Now) & "-" & Month(Now) & "-" & Day(Now) & ".txt"
Set txtFile = fs.CreateTextFile(strLogFileName, True)
On Error GoTo ErrorHandler
'Write header for text file
txtFile.WriteLine ("Importing records from " & sFileName & " on " & Now)
blnErrFlag = False
x = 0 'track number of lines
'Repeat for each line
Do Until ts.AtEndOfStream = True
s = ts.ReadLine
'create array
arrsubstring = Split(s, ","

strFolder = arrsubstring(36)
'Set Location of Contact File
sURL = sStartingURL & strFolder & "/"
'** Open a connection to the public folder using EXOLEDB provider
Set adoConn = New ADODB.Connection
With adoConn
.Provider = "exoledb.datasource"
.ConnectionString = sURL
.Mode = adModeReadWrite
.Open
End With
Call UpdateContact(sURL, arrsubstring(), adoConn)
Escape2:
Loop
ErrorHandler: 'and normal close
If Err.Number Then
txtFile.WriteLine "Error Occurred " & Err.Number & "-" & Err.Description & " at record DSM " & arrsubstring(36) & "-" & arrsubstring(0) & arrsubstring(2) & arrsubstring(3)
blnErrFlag = True
Err.Clear
Resume Escape2
End If
Escape:
'Close log file
ts.Close
txtFile.WriteLine ("***" & x & " records processed" & " on " & Now)
txtFile.Close 'Close Logfile
'Email Lyle
Set objEmail = CreateObject("CDO.Message"

objEmail.From = "administrator@test.com"
objEmail.To = "gbren@test.com"
If blnErrFlag = True Then
objEmail.Subject = "CSV to Contacts Failed"
objEmail.TextBody = "CSV to Contacts has run. There has been at least one error."
End If
If blnErrFlag = False Then
objEmail.Subject = "CSV to Contacts Successful"
objEmail.TextBody = "CSV to Contacts has run. There were no errors."
End If
objEmail.AddAttachment (strLogFileName)
objEmail.Send
End Sub
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'The following code was downloaded from
'and modified by gbren.
'
'* Developed by Quadrus Development Inc. *'
'*
*'
'* *'
'* Quadrus Development Inc. makes no representations or warranties respecting *'
'* this demo application and associated code including as to the accuracy, *'
'* completeness, reliability, or fitness for a particular use of the demo *'
'* application and associated code. *'
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' SUB UpdateContact
'
' Description: Update the corresponding Exchange contact record with
' the customer information from SQL Server.
' If the contact record does not exist, create it and
' initialize the service provider information.
'
' Parameters: strFolderURL - URL path to the Exchange public folder
' fldCust - fields of the customer record from SQL Server
' adoConn - ADO connection to the Exchange public folder
'
' Errors are logged to the event log but not propagated to the calling
' function. This is done so that the entire update procedure does not fail
' because of one customer
'
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Private Sub UpdateContact(strFolderURL As String, _
fldCust As Variant, _
adoConn As ADODB.Connection)
On Error GoTo ErrorHandler
Dim strContactURL As String
Dim cdoPerson As CDO.Person
Dim strCustomerID As String
Dim strFirstName As String
Dim strLastName As String
Dim strCompany As String
Dim strDSM As String
'** Retrieve customer ID and name information
strCustomerID = arrsubstring(39) 'Dealer #
strFirstName = arrsubstring(0) 'First Name
strLastName = arrsubstring(2) 'Last Name
strCompany = arrsubstring(3) 'Company
strDSM = arrsubstring(36) 'District Sales Mgr
'** Build the URL to the contact record in the Exchange public folder
'** We use Company, LastName, FirstName, and Customer ID as a unique readable filename
strFolderURL = "file://./backofficestorage/test.com/public folders/DealerBooks/" & strDSM & "/"
strContactURL = strFolderURL & strCompany & strLastName & strFirstName & strCustomerID & ".eml"
'** Turn off error checking while we try to open the contact using CDO
On Error Resume Next
Set cdoPerson = New CDO.Person
cdoPerson.DataSource.Open strContactURL, adoConn, adModeReadWrite, adFailIfNotExists
'** Check the error to see if a contact record does not yet exist
If Err.Number = ERR_CONTACT_NOT_FOUND Then
'** This is a new contact
'Update Form
Form1.lbl1.Caption = "Adding... " & arrsubstring(0) & arrsubstring(2) & arrsubstring(3)
txtFile.WriteLine ("Added... DSM " & arrsubstring(36) & "-" & arrsubstring(0) & arrsubstring(2) & arrsubstring(3))
Form1.Refresh
'** Reset the error handler
On Error GoTo ErrorHandler
'** Update the name fields and save the contact record
cdoPerson.FirstName = strFirstName
cdoPerson.LastName = strLastName
cdoPerson.Company = strCompany
cdoPerson.Title = strCustomerID
cdoPerson.DataSource.SaveTo strContactURL, adoConn
'** Open the contact record again so we can update the address info
cdoPerson.DataSource.Open strContactURL, adoConn, adModeReadWrite, adFailIfNotExists
ElseIf Err Then
'** A different error occurred; let the error handler take care of it
GoTo ErrorHandler
End If
'** Reset the error handler, which will still be in RESUME NEXT if no error occurred
On Error GoTo ErrorHandler
'** Update the person's contact information for new or existing records
cdoPerson.WorkCity = arrsubstring(7)
cdoPerson.WorkState = arrsubstring(8)
cdoPerson.WorkPostalCode = arrsubstring(9)
cdoPerson.WorkCountry = arrsubstring(10)
cdoPerson.HomeCity = arrsubstring(14)
cdoPerson.HomeState = arrsubstring(15)
cdoPerson.HomePostalCode = arrsubstring(16)
cdoPerson.HomeCountry = arrsubstring(17)
cdoPerson.WorkPhone = arrsubstring(25)
cdoPerson.WorkFax = arrsubstring(27)
cdoPerson.MobilePhone = arrsubstring(28)
cdoPerson.HomePhone = arrsubstring(30)
cdoPerson.HomeFax = arrsubstring(32)
cdoPerson.Email = arrsubstring(33)
cdoPerson.Email2 = arrsubstring(34)
cdoPerson.Email3 = arrsubstring(35)
cdoPerson.Title = arrsubstring(39) 'Dealer #
cdoPerson.HomeStreet = arrsubstring(11) & IIf(arrsubstring(12) <> "", vbCrLf & arrsubstring(12), ""

& IIf(arrsubstring(12) <> "", vbCrLf & arrsubstring(13), ""

cdoPerson.WorkStreet = arrsubstring(4) & IIf(arrsubstring(5) <> "", vbCrLf & arrsubstring(5), ""

& IIf(arrsubstring(6) <> "", vbCrLf & arrsubstring(6), ""

If cdoPerson.LastName = "" Then 'If there is no last name, use the business address as primary
cdoPerson.FileAsMapping = cdoMapToOrg
cdoPerson.MailingAddressID = cdoBusinessAddress
Else
cdoPerson.FileAsMapping = cdoMapToLastFirst
cdoPerson.MailingAddressID = cdoHomeAddress
End If
cdoPerson.Fields("urn:schemas:Contacts

rganizationmainphone"

= arrsubstring(26)
cdoPerson.Fields("urn:schemas:contacts:department"

= arrsubstring(36) 'DSM #
cdoPerson.Fields("urn:schemas:contacts

rofession"

= arrsubstring(37) 'Region
cdoPerson.Fields("urn:schemas:contacts:nickname"

= arrsubstring(38) 'Active/Inactive
'** Save the updates to the contact record
cdoPerson.Fields.Update
cdoPerson.DataSource.Save
'Update Form
Form1.lbl1.Caption = "Changing... " & arrsubstring(0) & arrsubstring(2) & arrsubstring(3)
txtFile.WriteLine ("Changing... DSM " & arrsubstring(36) & "-" & arrsubstring(0) & arrsubstring(2) & arrsubstring(3))
Form1.Refresh
'** Clean up
Set cdoPerson = Nothing
Exit Sub
ErrorHandler:
If Err.Number Then
txtFile.WriteLine "Error Occurred " & Err.Number & "-" & Err.Description & " at record DSM " & arrsubstring(36) & "-" & arrsubstring(0) & arrsubstring(2) & arrsubstring(3)
Err.Clear
End If
End Sub