You are here

Importing OS 9 Outlook Express Contacts

Error message

Deprecated function: strpos(): Passing null to parameter #1 ($haystack) of type string is deprecated in drupal_strip_dangerous_protocols() (line 1458 of /home2/crephoto/public_html/techblog/includes/common.inc).

Just because a product is abandonware doesn't mean your completely SOL. There are some great grass-roots resources online helping support users of older Macintosh systems and software.

I recently had a client who needed to import all of their Outlook Express contacts from an OS 9 machine into Address Book on their new Mac OS X machine. I found several methods and procedures, but the following sounded the most straightforward, so I tried it. It worked like a charm for me, so I'm posting it here.

Before proceeding, you'll need is a way to move files from the old OS 9 machine to the new OS X Mac. If your machines are networked, then just enable file sharing on the new machine and move it over that way. If you have a CD burner, you can do it that way.

Export

On the old Mac, open Outlook Express and export the address book to a file. Copy this file to the new Mac.

Import

On the new Mac, run the AppleScript located in /Library/Scripts/Mail Scripts/Import Addresses.scpt In case this script does not exist on your machine, I've included it below.

The Applescript will prompt you to choose the application. (Outlook Express). At the next dialog box, select "From Exported File". Navigate to where you saved the exported contacts, and select the file.

The script should process your contacts and import them to Mac OS X Address Book.

*That's it!*

As usual, YMMV.

(*
Import Addresses

Copyright © 2002 Apple Computer, Inc.

You may incorporate this Apple sample code into your program(s) without
restriction. This Apple sample code has been provided "AS IS" and the
responsibility for its operation is yours. You are not permitted to
redistribute this Apple sample code as "Apple sample code" after having
made changes. If you're going to redistribute the code, we require
that you make it clear that the code was descended from Apple sample
code, but that you've made changes.
*)

(*
This script is intended for users wishing to import their addresses from
Entourage, Outlook Express, Eudora, or Palm Desktop into Mail.

The Entourage and Outlook Express importers have the option of importing
directly from the application (if you have it on your computer) or importing
a text file that has been exported from either of these applications. If you
choose the direct import option, more of your data (like groups and categories)
will be preserved.
*)

global totalRecordsImported
global totalRecordsToImport
global done

set totalRecordsImported to 0
set totalRecordsToImport to 0
set done to false
my promptUserForApplication()
set finalDialog to "Import finished!"
tell application "Address Book" to save addressbook
if totalRecordsImported is equal to 1 then
delay 2
set recordsImportedText to "1 record imported."
else
delay 2
set recordsImportedText to (totalRecordsImported as string) & " records imported."
end if
if totalRecordsImported is not equal to 0 then
set finalDialog to finalDialog & return & return & recordsImportedText
activate
display dialog finalDialog
end if

on promptUserForApplication()
set scriptFolderLocation to my getScriptFolderLocation()
set myLocation to my getMyLocation()
set theResult to choose from list {"Entourage", "Outlook Express", "Palm Desktop", "Eudora", "Claris Emailer", "Netscape"} ¬
with prompt "Choose the application to import from:"
if theResult is not equal to false then
set theApplication to item 1 of theResult
if theApplication is equal to "Entourage" then
set typeOfImport to my chooseTypeOfImport("Entourage")
if typeOfImport is equal to "From Exported File" then
set theFile to my chooseFileToImport("Entourage", "Export Addresses", "")
set {everyFieldName, numberOfFields, allFieldData} to my processFile(theFile)
my importFromTabDelimited(everyFieldName, numberOfFields, allFieldData)
else
try
set theScript to load script alias (scriptFolderLocation & "Entourage.scpt")
on error
set theScript to load script (choose file with prompt "The script needs the helper script named 'Entourage' to proceed:")
end try
tell theScript
set totalRecordsImported to importFromEntourageDirectly(totalRecordsImported)
end tell
end if
else if theApplication is equal to "Outlook Express" then
set typeOfImport to chooseTypeOfImport("Outlook Express")
if typeOfImport is equal to "From Exported File" then
set theFile to chooseFileToImport("Outlook Express", "Export Addresses", "")
set {everyFieldName, numberOfFields, allFieldData} to my processFile(theFile)
my importFromTabDelimited(everyFieldName, numberOfFields, allFieldData)
else
try
set theScript to load script alias (scriptFolderLocation & "Outlook Express.scpt")
on error
set theScript to load script (choose file with prompt "The script needs the helper script named 'Outlook Express' to proceed:")
end try
tell theScript
set totalRecordsImported to importFromOutlookExpressDirectly(totalRecordsImported)
end tell
end if
else if theApplication is equal to "Claris Emailer" then
my emailerExplanatoryText()
else if theApplication is equal to "Netscape" then
my netscapeExplanatoryText()
else if theApplication is equal to "Palm Desktop" then
set theFile to chooseFileToImport("Palm Desktop", "Export", "In the Export dialog, choose the 'Contacts' module and 'Tab & Return' as your delimiter.")
set {everyFieldName, numberOfFields, allFieldData} to my processFile(theFile)
my importFromTabDelimited(everyFieldName, numberOfFields, allFieldData)
else if theApplication is equal to "Eudora" then
try
set theScript to load script alias (scriptFolderLocation & "Eudora.scpt")
on error
set theScript to load script (choose file with prompt "The script needs the helper script named 'Eudora' to proceed:")
end try
tell theScript
set totalRecordsImported to importFromEudora(totalRecordsImported)
end tell
end if
end if
end promptUserForApplication

on getScriptFolderLocation()
tell application "Finder" to set bootVolume to startup disk as string
set basePathToLibraryScripts to bootVolume & "Library:Scripts:Mail Scripts:Helper Scripts:"
return basePathToLibraryScripts
end getScriptFolderLocation

on getMyLocation()
set pathToMe to path to me as string
set AppleScript's text item delimiters to ":"
set pathToMyLocation to text items 1 thru -2 of pathToMe as string
set AppleScript's text item delimiters to ""
return pathToMyLocation
end getMyLocation

on emailerExplanatoryText()
set theResult to display dialog ¬
"To use addresses from Claris Emailer, open Emailer. Then choose Export Addresses from the File menu. Save the exported file in 'LDIF - Include Groups' format and click Continue." buttons {"Quit", "Continue"} default button 2
if button returned of theResult is equal to "Continue" then
set theResult to display dialog ¬
"Open Address Book, then choose LDIF from the Import submenu of the File menu. Choose the Emailer export file that you created. That's it, you're done!" buttons {"Quit", "Open Address Book"} default button 2
if button returned of the result is equal to "Open Address Book" then
tell application "Address Book"
activate
end tell
end if
end if
end emailerExplanatoryText

on netscapeExplanatoryText()
set theResult to display dialog ¬
"To use addresses from Netscape, open Netscape. Then choose Export Address Book File from the File menu. Save the exported file, then click Continue." buttons {"Quit", "Continue"} default button 1
if button returned of theResult is equal to "Continue" then
set theResult to display dialog ¬
"Open Address Book, then choose LDIF from the Import submenu of the File menu. Choose the Netscape export file that you created. That's it, you're done." buttons {"Quit", "Open Address Book"} default button 2
if button returned of the result is equal to "Open Address Book" then
tell application "Address Book"
activate
end tell
end if
end if
end netscapeExplanatoryText

on chooseTypeOfImport(theApplication)
display dialog "You can choose to import directly from " & theApplication & " if you have it available on this system, or you can import a file that has been exported from " & theApplication & "." & return & return & "With a direct import from " & theApplication & ", more of your data will be preserved."
display dialog "Choose the type of import you would like to perform:" buttons {"From Application", "From Exported File"} default button 2
set returnValue to button returned of the result
return returnValue
end chooseTypeOfImport

on chooseFileToImport(theApplicationName, theCommand, theExtraText)
set dialogText to "In order to import addresses from " & theApplicationName & ", you must first export them using the " & theCommand & " command from the File menu in " & theApplicationName & "."
if theExtraText is not equal to "" then
set dialogText to dialogText & return & return & theExtraText
end if
display dialog dialogText
display dialog "When clicking OK, you will then be asked to locate the file you exported from " & theApplicationName & "."
set returnValue to choose file with prompt "Select the exported file from " & theApplicationName & ":"
return returnValue
end chooseFileToImport

on processFile(theFile)
set scriptFolderLocation to my getScriptFolderLocation()
set theScript to load script alias (scriptFolderLocation & "Import Helper.scpt")
set theFileRef to open for access theFile
set theRawData to read theFileRef from 1 to eof
close access theFileRef
set AppleScript's text item delimiters to theScript's sniffLineDelimiter(theRawData)
set everyTextItem to every text item of theRawData
set AppleScript's text item delimiters to tab
set everyFieldName to every text item of text item 1 of everyTextItem
set numberOfEntries to count of everyTextItem
set numberOfFields to count of everyFieldName
set allFieldData to {}
repeat with counter from 2 to numberOfEntries
set everyField to every text item of text item counter of everyTextItem
set numberOfItems to count of everyField
if (numberOfItems is greater than or equal to numberOfFields) then
set thisEntry to {}
repeat with fieldCounter from 1 to numberOfFields
set thisEntry to thisEntry & text item fieldCounter of everyField
end repeat
set allFieldData to allFieldData & {thisEntry}
end if
end repeat
return {everyFieldName, numberOfFields, allFieldData}
end processFile

on importFromTabDelimited(everyFieldName, numberOfFields, allFieldData)
set scriptFolderLocation to my getScriptFolderLocation()
set theScript to load script alias (scriptFolderLocation & "Import Helper.scpt")
tell application "Address Book" to activate
repeat with eachItem in allFieldData
set appendToNotes to ""
tell application "Address Book" to set newEntry to make new person

-- Palm Desktop specific
set address1Label to ""
set address2Label to ""
set phone1Label to ""
set phone2Label to ""
set phone3Label to ""
set phone4Label to ""

repeat with counter from 1 to numberOfFields
set fieldName to item counter of everyFieldName
set thisItem to item counter of eachItem
if thisItem is not equal to "" then
if (fieldName begins with "First Name") then
theScript's setFirstName(newEntry, thisItem)
else if (fieldName begins with "Last Name") then
theScript's setLastName(newEntry, thisItem)
else if (fieldName is equal to "Title") then
theScript's setTitle(newEntry, thisItem)
else if (fieldName is equal to "Suffix") then
theScript's setSuffix(newEntry, thisItem)
else if (fieldName is equal to "Nickname") then
theScript's setNickname(newEntry, thisItem)
else if (fieldName is equal to "Company") then
theScript's setCompany(newEntry, thisItem)
else if (fieldName is equal to "Job Title") then
theScript's setJobTitle(newEntry, thisItem)
else if (fieldName begins with "Work Street Address") then
theScript's setStreetAddress(newEntry, "work", thisItem)
else if (fieldName is equal to "Work City") then
theScript's setCity(newEntry, "work", thisItem)
else if (fieldName is equal to "Work State") then
theScript's setState(newEntry, "work", thisItem)
else if (fieldName is equal to "Work Zip") then
theScript's setZip(newEntry, "work", thisItem)
else if (fieldName is equal to "Work Country/Region") then
theScript's setCountry(newEntry, "work", thisItem)
else if (fieldName is equal to "Work Phone 1") then
theScript's setPhone(newEntry, "work", thisItem)
else if (fieldName is equal to "Work Phone 2") then
theScript's setPhone(newEntry, "work 2", thisItem)
else if (fieldName begins with "Work Fax") then
theScript's setPhone(newEntry, "work fax", thisItem)
else if (fieldName begins with "Home Street Address") then
theScript's setStreetAddress(newEntry, "home", thisItem)
else if (fieldName is equal to "Home City") then
theScript's setCity(newEntry, "home", thisItem)
else if (fieldName is equal to "Home State") then
theScript's setState(newEntry, "home", thisItem)
else if (fieldName is equal to "Home Zip") then
theScript's setZip(newEntry, "home", thisItem)
else if (fieldName is equal to "Home Country/Region") then
theScript's setCountry(newEntry, "home", thisItem)
else if (fieldName is equal to "Home Phone 1") then
theScript's setPhone(newEntry, "home", thisItem)
else if (fieldName is equal to "Home Phone 2") then
theScript's setPhone(newEntry, "home 2", thisItem)
else if (fieldName begins with "Home Fax") then
theScript's setPhone(newEntry, "home fax", thisItem)
else if (fieldName is equal to "Other City") then
theScript's setCity(newEntry, "other", thisItem)
else if (fieldName is equal to "Other State") then
theScript's setState(newEntry, "other", thisItem)
else if (fieldName is equal to "Other Zip") then
theScript's setZip(newEntry, "other", thisItem)
else if (fieldName is equal to "Other Country/Region") then
theScript's setCountry(newEntry, "other", thisItem)
else if (fieldName begins with "Pager") then
theScript's setPhone(newEntry, "pager", thisItem)
else if (fieldName begins with "Mobile Phone" or fieldName begins with "Cell Phone") then
theScript's setPhone(newEntry, "mobile", thisItem)
else if (fieldName begins with "Main Phone") then
theScript's setPhone(newEntry, "main", thisItem)
else if (fieldName begins with "Assistant Phone") then
theScript's setPhone(newEntry, "assistant", thisItem)
else if (fieldName is equal to "Custom Phone 1") then
theScript's setPhone(newEntry, "custom 1", thisItem)
else if (fieldName is equal to "Custom Phone 2") then
theScript's setPhone(newEntry, "custom 2", thisItem)
else if (fieldName is equal to "Custom Phone 3") then
theScript's setPhone(newEntry, "custom 3", thisItem)
else if (fieldName is equal to "Custom Phone 4") then
theScript's setPhone(newEntry, "custom 4", thisItem)
else if (fieldName begins with "Email" or fieldName is equal to "E-mail") then
theScript's setEmail(newEntry, "other", thisItem)
else if (fieldName is equal to "Notes") then
set appendToNotes to thisItem & return & return & appendToNotes

-- Palm Desktop specific
else if (fieldName is equal to "Address 1 Label") then
set address1Label to thisItem
else if (fieldName is equal to "Address 2 Label") then
set address2Label to thisItem
else if (fieldName is equal to "Phone 1 Label") then
set phone1Label to thisItem
else if (fieldName is equal to "Phone 2 Label") then
set phone2Label to thisItem
else if (fieldName is equal to "Phone 3 Label") then
set phone3Label to thisItem
else if (fieldName is equal to "Phone 4 Label") then
set phone4Label to thisItem
else if (fieldName is equal to "Street 1 (Line 1)") then
theScript's setStreetAddress(newEntry, address1Label, thisItem)
else if (fieldName is equal to "Street 1 (Line 2)") then
theScript's setStreetAddress(newEntry, address1Label, thisItem)
else if (fieldName is equal to "City 1") then
theScript's setCity(newEntry, address1Label, thisItem)
else if (fieldName is equal to "State 1") then
theScript's setState(newEntry, address1Label, thisItem)
else if (fieldName is equal to "Zip 1") then
theScript's setZip(newEntry, address1Label, thisItem)
else if (fieldName is equal to "Country 1") then
theScript's setCountry(newEntry, address1Label, thisItem)
else if (fieldName is equal to "Street 2 (Line 1)") then
theScript's setStreetAddress(newEntry, address2Label, thisItem)
else if (fieldName is equal to "Street 2 (Line 2)") then
theScript's setStreetAddress(newEntry, address2Label, thisItem)
else if (fieldName is equal to "City 2") then
theScript's setCity(newEntry, address2Label, thisItem)
else if (fieldName is equal to "State 2") then
theScript's setState(newEntry, address2Label, thisItem)
else if (fieldName is equal to "Zip 2") then
theScript's setZip(newEntry, address2Label, thisItem)
else if (fieldName is equal to "Country 2") then
theScript's setCountry(newEntry, address2Label, thisItem)
else if (fieldName begins with "Phone 1") then
theScript's setPhone(newEntry, phone1Label, thisItem)
else if (fieldName begins with "Phone 2") then
theScript's setPhone(newEntry, phone2Label, thisItem)
else if (fieldName begins with "Phone 3") then
theScript's setPhone(newEntry, phone3Label, thisItem)
else if (fieldName begins with "Phone 4") then
theScript's setPhone(newEntry, phone4Label, thisItem)
else if (fieldName is equal to "Comments") then
set appendToNotes to thisItem & return & return & appendToNotes
else if (fieldName begins with "Category") then
theScript's assignPersonToGroup(newEntry, thisItem)
else if (fieldName is equal to "Marked" or fieldName is equal to "Modified" or fieldName is equal to "Private") then
-- skip these fields
else
set appendToNotes to appendToNotes & fieldName & ": " & thisItem & return
end if
end if
end repeat
theScript's setNotes(newEntry, appendToNotes)
set totalRecordsImported to totalRecordsImported + 1
if (totalRecordsImported mod 10 is equal to 0) then
tell application "Address Book" to save addressbook
end if
end repeat
end importFromTabDelimited