> I had some problems exporting my
> contacts to Entourage until I went through my Palm Desktop database and made
> sure every contact was consistent as far as telephone number labeling and
> placement (Phone1, 2, 3, 4).  Then the mapping ended up correct.

As far as I can tell, this will only work if you have the four label types
(Work, Home, School, something I forget) in that order.  That is, the label
returned by the following (see the full script below) :
    set theLabel to item 1 of (phoneRecord as list)
is NOT the label that Palm Desktop uses, which is controlled by the label
menu, nor is it the label the Palm uses.  The actual labels are in a
PhoneLabel object, but it is not clear to me how to get the correct label
from this given a phone record. Item one of phoneRecord is supposed to be a
reference to a Phonelabel according the dictionary, but I am not sure that
this is really correct.

Eric Hildum


The full script:
(*
    Import Palm Contacts
    
    Imports all of the contact information from Palm Desktop into Outlook
Express
    
    by Omar Shahine <mailto:[EMAIL PROTECTED]>
    based on a script by Dan Crevier

*)

-- loop through the names in Palm
tell application "Palm� Desktop"
    set contactCount to (count of every contact)
    repeat with contactNum from 1 to contactCount
        
        -- see if we already have a contact with this name
        set contactInfo to all fields of contact contactNum
        set userName to the full informal name of NameInfo of contactInfo
        set firstName to the first name of NameInfo of contactInfo
        set lastName to the last name of NameInfo of contactInfo
        set theCompany to company of NameInfo of contactInfo
        
        -- handle contacts with no user name, but with a company name
        -- in this case, we'll use the company name as the user name
        if the length of userName is 0 then
            set firstName to theCompany
            set userName to theCompany
        end if
        
        if the length of userName is greater than 0 then
            
            tell application "Outlook Express"
                if contact named userName exists then
                    set theContact to contact userName
                else
                    -- create a new contact
                    set theContact to make new contact with properties
{first name:firstName, last name:lastName}
                end if
                
            end tell
            
            -- import "NameInfo" stuff
            set theTitle to title of NameInfo of contactInfo
            set theDivision to division of NameInfo of contactInfo
            
            tell application "Outlook Express"
                set job title of theContact to theTitle
                set company of theContact to theCompany
                set department of theContact to theDivision
            end tell
            
            set contactDescription to comments of contactInfo & return
            -- append birthday to contacts if we have one
            if length of birthday of contactInfo is greater than 0 then
                set contactDescription to contactDescription & "Birthday: "
& birthday of contactInfo & return
            end if
            
            my importPostalAddress(Address1 of contactInfo, theContact)
            my importPostalAddress(Address2 of contactInfo, theContact)
            
            my importPhoneNumber(Phone1 of contactInfo, theContact)
            my importPhoneNumber(Phone2 of contactInfo, theContact)
            my importPhoneNumber(Phone3 of contactInfo, theContact)
            my importPhoneNumber(Phone4 of contactInfo, theContact)
            
            set contactDescription to my importCustom(Custom1 of
contactInfo, theContact, contactDescription)
            set contactDescription to my importCustom(Custom2 of
contactInfo, theContact, contactDescription)
            set contactDescription to my importCustom(Custom3 of
contactInfo, theContact, contactDescription)
            set contactDescription to my importCustom(Custom4 of
contactInfo, theContact, contactDescription)
            set contactDescription to my importCustom(Custom5 of
contactInfo, theContact, contactDescription)
            set contactDescription to my importCustom(Custom6 of
contactInfo, theContact, contactDescription)
            set contactDescription to my importCustom(Custom7 of
contactInfo, theContact, contactDescription)
            set contactDescription to my importCustom(Custom8 of
contactInfo, theContact, contactDescription)
            set contactDescription to my importCustom(Custom9 of
contactInfo, theContact, contactDescription)
            set contactDescription to my importCustom(Custom10 of
contactInfo, theContact, contactDescription)
            set contactDescription to my importCustom(Custom11 of
contactInfo, theContact, contactDescription)
            set contactDescription to my importCustom(Custom12 of
contactInfo, theContact, contactDescription)
            
            tell application "Outlook Express"
                set description of theContact to contactDescription
            end tell
        end if
    end repeat
end tell

-- import a postal address record into the correct postal address in Outlook
Express
on importPostalAddress(addressRecord, destContact)
    set theLabel to item 1 of (addressRecord as list)
    tell application "Outlook Express"
        if theLabel is "Home" then
            set home address of destContact to addressRecord
        else
            if theLabel is "Business" or theLabel is "Work" then
                set business address of destContact to addressRecord
            else
                if length of theLabel is greater than 0 then
                    set other address of destContact to addressRecord
                end if
            end if
        end if
    end tell
end importPostalAddress

-- import a phone number record into the correct phone number in Outlook
Express
on importPhoneNumber(phoneRecord, destContact)
    set theLabel to item 1 of (phoneRecord as list)
    set theNumber to item 2 of (phoneRecord as list)
    if length of theNumber is greater than 0 then
        tell application "Outlook Express"
            if the length of theLabel is greater than 0 then
                if theLabel is "Home" then
                    set home phone number of destContact to theNumber
                else
                    if theLabel is "Work" or theLabel is "Business" then
                        set business phone number of destContact to
theNumber
                    else
                        if theLabel is "Fax" then
                            set «class fxNm» of destContact to theNumber
                        else
                            if theLabel is "Cellular"  then
                                set cell phone number of destContact to
theNumber
                            else
                                if theLabel is "Pager" then
                                    set pager phone number of destContact to
theNumber
                                else
                                    if theLabel is "Car" then
                                        set «class crNm» of destContact to
theNumber
                                    else
                                        if theLabel is "Assistant" then
                                            set assistant phone number of
destContact to theNumber
                                        else
                                            if theLabel is "Main" then
                                                set main phone number of
destContact to theNumber
                                            else
                                                -- for a lack of a better
place to put it...
                                                set other phone number of
destContact to theNumber
                                            end if
                                        end if
                                    end if
                                end if
                            end if
                        end if
                    end if
                end if
            end if
        end tell
    end if
end importPhoneNumber

-- import a custom field into the appropriate place in Outlook Express
on importCustom(customRecord, destContact, contactDescription)
    set theLabel to item 1 of (customRecord as list)
    set theText to item 2 of (customRecord as list)
    if length of theText is greater than 0 then
        tell application "Outlook Express"
            if theLabel is "Email" then
                -- add email address if we don't already have it
                set addressList to every email address of destContact whose
contents is theText
                if number of items of addressList is 0 then
                    make new email address at destContact with data theText
                end if
            else
                if theLabel is "WWW" or theLabel starts with "Web" then
                    set home web page of destContact to theText
                else
                    if length of theLabel is greater than 0 then
                        set contactDescription to contactDescription &
theLabel & ": " & theText & return
                    end if
                end if
            end if
        end tell
    end if
    return contactDescription
end importCustom


--
To unsubscribe:               <mailto:[EMAIL PROTECTED]>
To search the archives:
          <http://www.mail-archive.com/entourage-talk%40lists.boingo.com/>

Reply via email to