I’d like to:
Select a folder of emails in Mail, then do a search to show only messages that contain text “X”. Easy enough to do by hand so far.
So then I need to send an email to the senders of all those found messages (preferably BCC). I can fill out the body of the message by hand.
Does anyone have a script to do this, or perhaps get all the senders of multiple selected messages? I’m good with scripting and have this sort of thing in Entourage but need this script to switch to Apple Mail soon.
While having a delicious breakfast I wrote the following script to get you started. The script will extract the senders of selected eMail messages in Apple Mail and create a new eMail message with the found senders added as BCC recipients.
Please note, that there is not yet a lot of error checking involved. For example, the script does not care for multiple occurences of an eMail address.
tell application "Mail"
set msgs to selection as list
-- creating a list of found message senders
set msgsenders to {}
repeat with msg in msgs
set msgsender to sender of msg
set msgsendername to extract name from msgsender
set msgsenderaddr to extract address from msgsender
set msgsenders to msgsenders & {{msgsendername, msgsenderaddr}}
end repeat
-- creating a new message with the found senders as BCC recipients
set newmsg to make new outgoing message with properties {visible:true}
repeat with msgsender in msgsenders
log msgsender
set msgsendername to item 1 of msgsender
set msgsenderaddr to item 2 of msgsender
tell newmsg
make new bcc recipient at end of bcc recipients with properties {address:msgsenderaddr, name:msgsendername}
end tell
end repeat
end tell