Reputation: 21
tho is my first post - glad to have found this community :)
I'm afraid I have limited applescript knowledge but I discovered a script that will create a new message with recipients based on senders of emails in a particular mailbox.
This is almost what I need...
What I really need is a script that will create a new message with recipients based on senders of all selected emails.
I am actually astonished that this is not an option in more mail clients. It's not an option in Mail, nor Mailmate, nor Entourage.
The code I am working with is...
tell application "Mail"
set theSenderList to {}
set theMailboxes to the selected mailboxes of message viewer 0
repeat with aMailbox in theMailboxes
repeat with aMessage in messages of aMailbox
set end of theSenderList to sender of aMessage
end repeat
end repeat
set newMessage to make new outgoing message with properties {visible:true, subject:"Answers to ", content:"Here is the solution to "}
repeat with aSender in theSenderList
tell newMessage
make new bcc recipient at end of bcc recipients with properties {address:aSender}
end tell
end repeat
end tell
Upvotes: 2
Views: 1711
Reputation: 77400
To access the selected messages, you can simply use selected messages
instead of selected mailboxes
. Once you've made this change, the loop over the selected mailboxes no longer applies. Instead, keep just the inner loop over messages.
...
set theMessages to the selected messages of message viewer 0
repeat with aMessage in theMessages
set end of theSenderList to sender of aMessage
end repeat
...
To find this sort of thing yourself:
You can also open a scripting dictionary via File → Open Dictionary..., or with ⇧⌘O.
In the properties for the message viewer, you'll see both "selected messages" and "selected mailbox".
The dictionary viewer uses a number of icons in the browser to indicate the type for a term
Upvotes: 2