From: "Entourage:mac Talk" <[EMAIL PROTECTED]>
Date: Fri, 9 Aug 2002 20:00:01 -0700
To: "Entourage:mac Talk" <[EMAIL PROTECTED]>
Subject: Entourage-Talk Digest - 08/09/02
First, copy the script and paste into Script Editor. Save it into "EntourageFrom: Allen Watson <[EMAIL PROTECTED]>
Script Menu items" folder, as a compiled script.
In Entourage, open a message with multiple recipients. From the Script menu
(with the little scroll icon), select the script you just saved. That runs
it.
Date: Thu, 08 Aug 2002 13:08:52 -0700
Subject: Re: Importing CCed Contacts
On or near 8/7/2002 3:38 PM, Marc Lambert at [EMAIL PROTECTED] observed:
> I know Cmd-= adds a sender to the addressbook, but is there any means for
> importing contacts from an email’s cc-ed recipients? I’ve received an email
> with a large number of cc-ed company contacts replete with full names so
> would like to add them to my address book and as a new category. E2001,
> OS9.2.2
>
The following script will add all the recipients to your address book as a GROUP (either a new group, or added to an existing group). I call it “Make Group from Recipients”.
You could then access them easily as a group. Will that serve the same purpose as assigning them a category?
tell application "Microsoft Entourage"
activate
set theMessage to "none"
try
set theMessage to item 1 of (get current messages)
on error
display dialog "The sent message with addresses must be open in the front window."
return
end try
if the class of the front window is not draft window then
if (the class of theMessage is not incoming message) and ¬
(class of theMessage is not outgoing message) then
display dialog "This script works only on incoming, outgoing, or previously sent
messages."
return
end if
else
save the front window
set theMessage to the displayed feature of the front window
end if
set groupList to name of every group --
try
set groupList to my sortList(groupList)
end try
set groupList to {"New Group...", "----------"} & groupList
set thegroup to ""
repeat while (thegroup = "") or (thegroup = "----------")
set thegroup to (choose from list groupList with prompt "Add senders to which group? " without multiple selections allowed) as text --
end repeat
if thegroup = "New Group..." then
display dialog "Enter name for new group." default answer "" buttons {"OK"} default button 1
set thegroup to text returned of result
try
set X to group thegroup -- See if group already exists
display dialog "Group already exists. Choose a new name or select it from the group list."
return
end try
make new group with properties {name:thegroup}
set theMembers to {}
else
if (count of group entries of group thegroup) � 0 then
set theMembers to group entries of group thegroup
else
set theMembers to {}
end if
end if
set theList to {}
repeat with aMember in theMembers
set theList to theList & address of content of aMember
end repeat
set theRecipients to the recipients of theMessage
display dialog "Use email addresses as shown, or look up default for contact?" buttons {"As shown", "Look up"}
set howToUse to button returned of result
repeat with aRecipient in theRecipients
set anAddress to address of aRecipient
set aName to the display name of anAddress
set anEmail to address of anAddress
if aName = "" then set aName to anEmail as text
try
set aContact to contact (aName as text)
on error
try
set aContact to find anEmail -- Returns list
set aContact to item 1 of aContact -- Take first match
on error
if howToUse is "Look Up" then
display dialog "Contact " & aName & " not found in address book. Add to Address Book, abort, or skip?" buttons {"Add", "Abort", "Skip"} default button 1
if button returned of result is "Abort" then
return
else if button returned of result is "Skip" then
set aContact to ""
else
set aContact to make new contact with properties {address:anEmail, display name:aName, description:thegroup}
end if
end if
end try
end try
if howToUse is "Look up" then
if aContact is not "" then
if anEmail is not in theList then
make new group entry of group thegroup with properties {content:aContact}
else
display dialog aName & " is already a member"
end if
end if
else
if anEmail is not in theList then
make new group entry of group thegroup with properties {content:anEmail}
else
display dialog anEmail & " is already a member."
end if
end if
end repeat
try
say "Group updated."
on error
display dialog "Group updated."
end try
end tell
on sortList(l)
set testClass to class of item 1 of l
repeat with j from 1 to count l
if class of (item j of l) is not testClass then
display dialog "Cannot sort lists of mixed class."
error 128
end if
end repeat
if length of l � 1 then return l
set X to item 1 of l
set ll to rest of l
set l1 to {}
set l2 to {}
repeat with i in ll
if X < i then
set l2 to l2 & i
else
set l1 to l1 & i
end if
end repeat
if length of l1 > 1 then set l1 to sortList(l1)
if length of l2 > 1 then set l2 to sortList(l2)
return l1 & X & l2
end sortList
