|
|
Change Mail behavior when replying to a message in the Sent mailbox
Others have covered the features of Mail (and plugins) that make this script's utility questionable, so I'll confine my comments to the Applescript code.
Original: set theMessages to the selected messages of the front message viewer This line is very problematic, because it will not work if there is more than one message viewer open, and the front MV is not the first one opened. This will fix that: set theMessages to the selected messages of some message viewer whose index is 1 Let us also please have at least basic error-checking:
try # Script Body on error errMsg number errNum set sep to "==============================" set e to sep & return & "Error: " & errMsg & return & sep & return ¬ & "Error Number: " & errNum & return & sep beep display dialog e end try Setting aside the merits of the script, let's rewrite it in more sturdy fashion just for the exercise:
tell application "Mail"
try
set quoteOriginalMessagePref to quote original message
set selectedMsg to (get selected messages of some message viewer whose index is 1)'s 1st item
if selectedMsg's mailbox's name = "Sent Messages" then
tell selectedMsg
set recipientList to {name, address} of its recipients
set newOutgoingMessage to reply with opening window
end tell
delay 0.05 # This value might need adusting to allow the quoted material to show up.
if quoteOriginalMessagePref = true then set quote original message to false
tell newOutgoingMessage
set address of to recipients to ""
repeat with ndx from 1 to length of (item 1 of recipientList)
make new recipient at end of to recipients with properties ¬
{name:item ndx of item 1 of recipientList, address:item ndx of item 2 of recipientList}
end repeat
end tell
if quoteOriginalMessagePref then set quote original message to true
else
error "Selected Messages Not in 'Sent Messages' Mailbox"
end if
on error errMsg number errNum
try
set quote original message to quoteOriginalMessagePref
end try
set sep to "=============================="
set e to sep & return & "Error: " & errMsg & return & sep & return ¬
& "Error Number: " & errNum & return & sep
beep
display dialog e
end try
end tell
Kudos to the O.P. for figuring a way around Mail's evil multiple-quotation bug. I prefer to run this sort of thing with FastScripts (a recent MacGem), because it handles app-specific keyboard shortcuts better than Mac OS X's service menu and has other useful features. -ccs Edited on Jun 15, '11 03:05:43AM by ccstone
|
SearchFrom our Sponsor...Latest Mountain Lion HintsWhat's New:HintsNo new hintsComments last 2 daysNo new commentsLinks last 2 weeksNo recent new linksWhat's New in the Forums?
Hints by TopicNews from Macworld
From Our Sponsors |
|
Copyright © 2014 IDG Consumer & SMB (Privacy Policy) Contact Us All trademarks and copyrights on this page are owned by their respective owners. |
Visit other IDG sites: |
|
|
|
Created this page in 0.07 seconds |
|