Apr 27, '04 10:34:00AM • Contributed by: Apollo18Pnut
Obviously, replace firstname.lastname@gmail.com with the intended recipient of your redirected emails, and name with the full text of what you want to appear in the "Account" dropdown (i.e., the account that you want to use to send the redirected emails).
using terms from application "Mail"
on perform mail action with messages selectedMessages
set AppleScript's text item delimiters to ""
set theRedirectRecipient to "firstname.lastname@gmail.com"
set theRedirectSender to "name <name@fastmail.fm>"
repeat with eachMessage in selectedMessages
tell application "Mail"
(* Uncomment this block and the "end if" below
to ask if it's ok to forward each email
set theSubject to the subject of eachMessage
set theResult to display dialog "Redirect " & theSubject & ¬
" to Gmail?" buttons {"OK", "Cancel"} default button 1
if button returned of theResult is equal to "OK" then
*)
set theRedirectedEmail to redirect eachMessage ¬
with opening window
tell theRedirectedEmail
make new to recipient at beginning of to recipients ¬
with properties {address:theRedirectRecipient}
end tell
set the sender of theRedirectedEmail to theRedirectSender
send theRedirectedEmail
(* Also uncomment this block
end if
*)
end tell
end repeat
end perform mail action with messages
end using terms from
That should do it. Save the AppleScript in your user's Library -> Scripts -> Mail Scripts folder, and you're good to go.
