Option Public Option Declare ' [DO NOT REMOVE - BEGIN] ' Copyright (C) 1999 Andrew Cottrell ' This program is free software; you can redistribute it and/or modify ' it under the terms of the GNU General Public License as published by ' the Free Software Foundation; either version 2 of the License, or ' (at your option) any later version. ' This program is distributed in the hope that it will be useful, ' but WITHOUT ANY WARRANTY; without even the implied warranty of ' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ' GNU General Public License for more details. ' For a copy of the GNU General Public License write to: ' The Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. ' You can view a copy of the GNU General Public License online at: ' http://www.gnu.org/copyleft/COPYING ' [DO NOT REMOVE - END] %INCLUDE "lsconst.lss" Const DEBUG = False Const TITLE = "Import Outlook Address Book" Const FORM = "Person" Class classRecord Public Field(1 To 29) As String End Class Dim session As notesSession Dim dbCurrent As notesDatabase Sub Initialize If Not DEBUG Then On Error Goto Error_Handler If SetGlobals Then ProcessFile Exit Sub Error_Handler: Messagebox Error$(Err), MB_OK, TITLE Exit Sub End Sub Function SetGlobals Set session = New notesSession Set dbCurrent = session.CurrentDatabase If dbCurrent Is Nothing Then SetGlobals = False Else SetGlobals = True End If End Function Sub ProcessFile Dim Filename As String Dim FileNumber As Integer Dim Record As classRecord filename = Inputbox$("Filename?", TITLE, "") FileNumber = Freefile Open Filename For Input Access Read As #FileNumber Len=30000 Do While Not Eof(FileNumber) Set Record = GetRecord(FileNumber) ProcessRecord Record Loop Close #FileNumber End Sub Function GetRecord(FileNumber As Integer) As classRecord Const COMMA = |,| Const QUOTE = |"| Dim FileLine As String Dim Record As classRecord Dim FieldCounter As Integer Dim CommaPos As Integer Dim QuotePos As Integer Dim sRecord As String Set Record = New classRecord Line Input #FileNumber, FileLine sRecord = FileLine For FieldCounter = 1 To 29 QuotePos = Instr(sRecord, QUOTE) If QuotePos = 1 Then sRecord = Right$(sRecord, Len(sRecord) - 1) Do While Instr(sRecord, QUOTE) = 0 Line Input #FileNumber, FileLine sRecord = sRecord & Chr$(13) & FileLine Loop QuotePos = Instr(sRecord, QUOTE) Record.Field(FieldCounter) = Left$(sRecord, QuotePos - 1) If Not (Len(sRecord) = QuotePos) Then sRecord = Right(sRecord, Len(sRecord) - QuotePos - 1) End If Else CommaPos = Instr(sRecord, COMMA) If CommaPos = 0 Then If FieldCounter = 29 Then Record.Field(FieldCounter) = sRecord Else Print "Comma expected, but not found." End If Else Record.Field(FieldCounter) = Left$(sRecord, CommaPos - 1) sRecord = Right$(sRecord, Len(sRecord) - CommaPos) End If End If Next FieldCounter Set GetRecord = Record End Function Sub ProcessRecord(Record As classRecord) Dim docPerson As notesDocument Dim cr As String cr = Chr$(13) Set docPerson = dbCurrent.CreateDocument docPerson.Type = FORM docPerson.Form = FORM docPerson.Name = Record.Field(4) docPerson.Title = "5" docPerson.FirstName = Record.Field(1) docPerson.MiddleInitial = Record.Field(3) docPerson.LastName = Record.Field(2) docPerson.Suffix = "" docPerson.JobTitle = Record.Field(26) docPerson.CompanyName = Record.Field(25) docPerson.BusinessAddress = Record.Field(16) + cr + Record.Field(17) + cr + Record.Field(19) docPerson.OfficeZip = Record.Field(18) docPerson.OfficeContry = Record.Field(20) docPerson.OfficePhoneNumber = Record.Field(22) docPerson.OfficeFaxPhoneNumber = Record.Field(23) docPerson.CellPhoneNumber = Record.Field(14) docPerson.PhoneNumber = Record.Field(12) docPerson.HomeFaxPhoneNumber = Record.Field(13) docPerson.PhoneNumber_6 = Record.Field(24) docPerson.MailAddress = Record.Field(6) docPerson.WebSite = Record.Field(15) docPerson.HomeAddress = Record.Field(7) + cr + Record.Field(8) + cr + Record.Field(10) docPerson.Zip = Record.Field(9) docPerson.Country = Record.Field(11) docPerson.Categories = "" docPerson.Comment = Record.Field(29) + cr + cr + Record.Field(21) docPerson.Location = Record.Field(28) docPerson.Department = Record.Field(27) docPerson.Manager = "" docPerson.Assistant = "" docPerson.Spouse = "" docPerson.Children = "" Call docPerson.Save(True, False) End Sub