I am new to the AppleScript language and just recently decided to try and tackle this problem: my friend would like me to write a script that will select an amended email signature in Apple’s Mail client for a reply to a conversation he initiated, (there will only be two total signatures, the first being a full email signature and the second being an amended shorter version).
So essentially when he composes a new email, the script will automatically choose the full signature and then, if after there is a reply to his email, he replies to the same thread, the second, shorter email signature will be chosen. (Basically he wants to keep all that signature info from unnecessarily repeating throughout the convo, and he can’t be relied on to change his signature manually, haha).
So there is the challenge, and up until now, I have been trying to call the script whenever a new compose window is opened (I was doing this with the help of SignatureProfiler’s ability to call a script from the signature). After a new message had been opened, I was then trying to access the properties of that message to evaluate it’s position w/in the conversation, (i.e. “is it a reply?”, etc.). The problem is that accessing the properties (including the content) of an existing mail message displayed in its own window, which is frontmost, is not possible… (at least from what I can tell).
Does anyone here have any ideas on how to go about tackling this problem, esp. about how to call the script in the first place w/ out having to rely on a third party plugin… or would this problem require the creation of a plugin of its own to accomplish what I want?
This little problem has really stumped me and now is consuming my thoughts! haha. Any input/help would greatly be appreciated!
Here is something to get you started.
You can’t amend an extra signature to the signatures in mail. That is bound the last text in the mail message.
You can work around with inserting some template text when you create a new message, and replicating the original signature in that message, -which may be a tough job if it contains links and such. and then inserting the amended signature. or using that “amended” signature as the real signature.
And you can call the script from the script menu, or from your favorite short-cut key utility. Since we are not storing any properties in this script, you can use any short-cut key utility you want.
Spark is a great free shortcut utility that stores the properties of an Applescript. “Spark+download” via google should get you right to it.
What you want, is to make your friend understand that a prepended signature is so much better!
(At least I and others use to prepend signatures when we want it to be a wee bit more personal. An it is a lot easier to implement.) You then just run a script after you have composed the message, which inserts your "amendment of the contents / header of the signature.
tell application "Mail"
activate
set theMsg to make new outgoing message with properties {visible:true}
set message signature of theMsg to signature "McUsr"
end tell
Example of text amended to the contents:
Context: your friend set the signature to “None” before running this script.
The script then amends some contents to the content, and then it turn the correct signature on.
tell application "Mail"
set outMId to (get first outgoing message)
tell outMId
set myCont to get its content -- of outMId
set myCont to myCont & "
See you soon!
"
set its content to myCont
set its message signature to signature "McUsr"
end tell
end tell
Edit: The easiest thing would of course be to create an extra set of signatures with the text amended in the first place, there is no more job in selecting a different signature than there is to run a script to do it for you.