At work, people send email asking for help. It's our practice to respond to the email letting the sender know we are working on it even if we don't have the answer right away.
This seemed like a perfect application for
AppleScript.
The first applescript example I found that seemed relevant was to
Extract the name and email from selected messages. This showed me how to operate on a list of messages, but I wanted to compose a reply.
I was wondering how people knew what you could script with each application when I found out that
Script Editor has a
Dictionary Browser. Whoa! Way cool.
Now I could compose a reply. All I needed to do was insert my text and I was done. Wow, this was really easy.
Naturally, I was wrong.
I simply couldn't find an example of inserting text into the reply. If I tried concatenating my text with the text of the reply, then the reply lost all of its formatting (e.g. the original text was no longer quoted). The only reference I could find was to use
call method, but Script Editor would give me a syntax error every time.
I was really pulling my hair out now. I seemed so close. I looked at the
AppleScript Terminology Reference, but that didn't provide any clues.
I looked at the Data Dictionary again and I noticed the 'make new' command. Maybe I could create a new text object and concatenate it with the quoted reply.
That's when I found a script to
Send an email with an attachment. It had the very interesting
make new attachment.
Maybe I could create a new text object the same way. Bingo!
using terms from application "Mail"
on perform mail action with messages selectedMessages
set AppleScript's text item delimiters to ""
repeat with eachMessage in selectedMessages
tell application "Mail"
set theReplyEmail to reply eachMessage with opening window and reply to all
make new text at before the first word of the first paragraph of content of theReplyEmail with data "Working on it." & return & return & "Drew" & return & return
send theReplyEmail
end tell
end repeat
end perform mail action with messages
end using terms from
Somewhere in
this thread is a tip that explains how to use System Preferences-> Keyboard and Mouse to set up a keyboard shortcut for a script. You need to restart Mail.app for it to take effect.
I used this suggestion to create a script to add a salutation based on the first name of the person writing the email to which you are responding, as Sister Mary Battleship insisted that I do when I was a kid. Now it’s basically effortless to create an email message with a proper Dear you, content blah blah, Sincerely, Me format.
Thanks!