Title: Re: Extracting addresses from a folder
On 3/11/01 11:57 AM, "Pareti, Jason" <[EMAIL PROTECTED]> wrote:
> Is there any method or script for extracting a list of the "To:" addresses
> from each message in a folder? I searched online and haven't found anything
> so far.
>
> I have a particular folder which contains 500+ emails from the past few
> years that I've sent out. I'd really love to capture all of the "To"
> addresses so that I can send a new announcement to everyone (using bcc)
> without having to manually copy and paste 500 email addresses.
>
> Any ideas or help would be greatly appreciated!
>
Everything can be done by AppleScript. Paste this script into Script Editor or Smile, and save it to your Entourage Script Menu Items folder in Documents:Microsoft User Data folder. Then just select the folder in question in your folder list so it is displayed in the message pane, and run the script by selecting it in the Script menu. It will add every sender to an existing Group (use it this way if you add more messages to this folder) or make a new group for you (this time) of all the senders, without duplications. It also asks you if you want to make real contacts out of any senders which aren't contacts yet (again, no duplications). It opens the group for you at the end so you know it's done: any group entries who are contacts will have the contact icon, the others will have @ icons. Any time you want to email to everyone, just autofill or drag the group name into the To, CC, or BCC field of a message, and that's it. (If you want to give the group a category and then apply the category to all the group members, get my script Apply Group Category at AppleScript Central <http://www.applescriptcentral.com/> ).
--------------------------ADD SENDERS TO GROUP-------------------
tell application "Microsoft Entourage"
set theFolder to displayed feature of main window
if class of theFolder � folder then
beep
display dialog "! You must first select a folder." buttons {"OK"} default button "OK" with icon 0
return
end if
set folderName to name of theFolder
set theMsgs to every incoming message of theFolder
if theMsgs = {} then
beep
display dialog "! There are no received messages in " & folderName & " folder." buttons {"OK"} default button "OK" with icon 2
return
end if
display dialog "Add the senders of these messages to an existing group, or make a new one?" buttons {"Cancel", "New Group", "Existing Group"} default button "Existing Group" with icon 1
if button returned of result = "Cancel" then
return
else if button returned of result = "Existing Group" then
set allGrps to name of every group
set groupName to (choose from list allGrps with prompt "Add names and addresses to which group?") as string
if groupName = "false" then return
set theGroup to group groupName
else
display dialog "Enter a name for the new group:" default answer folderName with icon 1
set groupName to text returned of result
set check to false
repeat until check is true
if exists group groupName then
display dialog "! There already exists a " & groupName & "group." & return & return & "Add senders to " & groupName & " group, or choose a new name for your new group." & return & return & "(Pick another name:)" default answer "" buttons {"Cancel", groupName, "New Name"}
if button returned of result = "Cancel" then
return
else if button returned of result = groupName then
set check to true
set theGroup to group groupName
else
set groupName to text returned of result
if not (exists group groupName) then
set check to true
set theGroup to make new group with properties {name:groupName}
end if
end if
else
set check to true
set theGroup to make new group with properties {name:groupName}
end if
end repeat
end if
display dialog "Do you want to make a new contact in your Address Book as well for any sender not already there?" buttons {"Yes", "No"} default button "No" with icon 1
set makeContact to button returned of result
try
set theEntries to content of every group entry of theGroup
on error -- new group, no entries yet
set theEntries to {}
end try
repeat with i from 1 to count theMsgs
set theMsg to item i of theMsgs
set theSender to sender of theMsg
set {eAddress, dName} to theSender's {address, display name}
set haveContact to find eAddress
if makeContact = "Yes" then -- do first to include contact icon in group listing
if haveContact = {} then
if dName � "" then
set AppleScript's text item delimiters to {space}
set lName to last text item of dName
try -- if more than one name
set fName to "" & text items 1 thru -2 of dName
on error
set fName to ""
end try
set AppleScript's text item delimiters to {""}
else
set {fName, lName} to {"", ""}
end if
set theContact to make new contact with properties {last name:lName, first name:fName}
make new email address at theContact with properties {contents:eAddress}
set haveContact to {theContact}
end if
end if
if {theSender} is not in theEntries then
set end of theEntries to theSender
if haveContact � {} then
set newEntry to item 1 of haveContact -- as contact
else
set newEntry to "<" & eAddress & ">"
if dName � "" then set newEntry to dName & " " & newEntry
end if
make new group entry at theGroup with properties {content:newEntry}
end if
end repeat
open theGroup
end tell
-------------------END SCRIPT-----------------------------------
--
Paul Berkowitz
- Extracting addresses from a folder Pareti, Jason
- Re: Extracting addresses from a folder Paul Berkowitz
- Re: Extracting addresses from a folder Allen Watson
