--
set configuration_address_index to 1
set configuration_phone_home_label to "home"
set configuration_phone_fax_label to "fax"
set configuration_email_home_label to "home"
--
tell application "Contacts"
--
set selectedItems to selection
if ((count of selectedItems) is not 1) then
return
end if
--
set selectedItem to first item of selectedItems
--
set someText to ""
set allLines to {}
--
set someText to my getNameDescriptionFromPerson(selectedItem)
if (someText is not missing value) then
copy someText to the end of allLines
end if
--
set someText to my getAddressAtIndexFromPerson(configuration_address_index, selectedItem)
if (someText is not missing value) then
copy someText to the end of allLines
end if
--
set someText to my getPhoneWithLabelFromPerson(configuration_phone_home_label, selectedItem)
if (someText is not missing value) then
set someText to "T: " & someText
copy someText to the end of allLines
end if
--
set someText to my getPhoneWithLabelFromPerson(configuration_phone_fax_label, selectedItem)
if (someText is not missing value) then
set someText to "F: " & someText
copy someText to the end of allLines
end if
--
set someText to my getEmailWithLabelFromPerson(configuration_email_home_label, selectedItem)
if (someText is not missing value) then
set someText to "E: " & someText
copy someText to the end of allLines
end if
--
set AppleScript's text item delimiters to return
--
set someText to allLines as text
--
end tell
--
if (length of someText < 1) then
return
end if
--
set the clipboard to someText
--
return someText
--
on getNameDescriptionFromPerson(aPerson)
--
if (aPerson is missing value) then
return missing value
end if
--
set someText to name of aPerson
--
if ((length of someText) < 1) then
return missing value
end if
--
return someText
--
end getNameDescriptionFromPerson
--
on getAddressAtIndexFromPerson(aIndex, aPerson)
--
if (aPerson is missing value) then
return missing value
end if
--
if (aIndex < 1) then
return missing value
end if
--
tell application "Contacts"
--
set allAddresses to address of aPerson
if (aIndex ≤ (count of allAddresses)) then
--
else
return missing value
end if
--
set firstAddress to item aIndex of allAddresses
--
set someText to ""
set allLines to {}
--
set someText to street of firstAddress
if (someText is not missing value) then
copy someText to the end of allLines
end if
--
set someText to zip of firstAddress
if (someText is not missing value) then
--
copy someText to the end of allLines
--
set someText to city of firstAddress
if (someText is not missing value) then
set someText to last item of allLines & " " & someText
set last item of allLines to someText
end if
--
else
--
set someText to city of firstAddress
if (someText is not missing value) then
copy someText to the end of allLines
end if
--
end if
--
set someText to country of firstAddress
if (someText is not missing value) then
copy someText to the end of allLines
end if
--
end tell
--
set AppleScript's text item delimiters to return
--
set someText to allLines as text
--
if ((length of someText) < 1) then
return missing value
end if
--
return someText
--
end getAddressAtIndexFromPerson
--
on getPhoneWithLabelFromPerson(aLabel, aPerson)
--
if (aPerson is missing value) then
return missing value
end if
--
tell application "Contacts"
--
set someList to phones of aPerson
--
end tell
--
set someValue to my getValueFromListWithLabel(someList, aLabel)
--
return someValue
--
end getPhoneWithLabelFromPerson
--
on getEmailWithLabelFromPerson(aLabel, aPerson)
--
if (aPerson is missing value) then
return missing value
end if
--
tell application "Contacts"
--
set someList to emails of aPerson
--
end tell
--
set someValue to my getValueFromListWithLabel(someList, aLabel)
--
return someValue
--
end getEmailWithLabelFromPerson
--
on getValueFromListWithLabel(aList, aLabel)
--
if ((count of aList) < 1) then
return missing value
end if
--
tell application "Contacts"
--
repeat with nItem in aList
--
set someLabel to label of nItem
if (someLabel is aLabel) then
--
set someValue to value of nItem
if (length of someValue > 0) then
return someValue
end if
--
end if
--
end repeat
--
end tell
--
return missing value
--
end getValueFromListWithLabel