UPDATED to be more practical.
Mail citation.
This is a rather small script to generate a citation in your Mail.app mail signature.
It won’t be able to generate citations dynamically since you have to restart mail to get the
new citation, but you can run the script until you get a new citation you are pleased with and from
then on fire up mail.
Additional installs.
If you haven’t installed fortune from macports you must first to so.
Then you can obtain the path of the fortune program with “which fortune” in a terminal window.
-And there are options for the commandline like -s for short messages, which can be found
by googling “man fortune”.
Modifications of the original script (the upcoming).
First of all you have to go to the Mail.app preferences and create a signature, with something
in ( a "Test citation below your salutation) it so you can differentiate that file from your others without a signature.
After you have created your signature file save it! -hit cmd-S, or maybe it is just me, but I had
problems finding the web-archive files before I had hit cmd-S in the signatures window.
Then you go to ~/Libraries/Signatures folder and finds the web-archieve file which correlate
to your signature. – You can watch the list in the script to differentiate with previous entries.
Then you insert this filename into this script. The easies way is to drag the webarchieve into the editor
between two hyphens in the list.
Having reached this far, it is now time to experiment with geting rid of the test salutition
this is accomplished with this little snippet. -Find out first the last paragraph you want to keep
-any newlines below your salutation.
Save the script when you are satisfied and run it until you have a citation you like.
Fire up Mail.app and try it.
Here is the snippet:
set myText to do shell script "/opt/local/bin/fortune -s"
property signData : {{"English Formal", "/Users/McUsr/Library/Mail/Signatures/83957040-3796-458F-9027-28BFEAEAB69B.webarchive", 6}, ¬
{"McUsr", "/Users/McUsr/Library/Mail/Signatures/FD4C6074-118B-4689-A601-69FA9DEE5AC9.webarchive", 5}, ¬
{"McUser06", "/Users/McUsr/Library/Mail/Signatures/C30E94E5-4025-4799-8B62-92572ACDA215.webarchive", 6}, ¬
{"Another one", "/Users/McUsr/Library/Mail/Signatures/374EB2B7-5FBD-41D9-A174-6E1B8CD3F302.webarchive", 7}}
property newList : {}
set newList to {}
repeat with anItem in every item of signData
set end of newList to item 1 of anItem
end repeat
try
set signatureName to choose from list newList with title "Choose Signature to update"
on error
error number -128
end try
if not signatureName is false then
-- display dialog m
set found to false
set ctr to 0
considering case
repeat with anItem in every item of signData
if (item 1 of anItem as text) is (signatureName as text) then set found to true
set ctr to ctr + 1
if found is true then exit repeat
end repeat
end considering
if found then
set signatureFile to POSIX file (item 2 of item ctr of signData as text) as alias
set lastStaticParagraph to (item 3 of item ctr of signData as number)
-- display dialog ctr
-- display dialog item 2 of item ctr of signData
end if
tell application "TextEdit"
open signatureFile
tell text of document 1
delete (paragraphs (lastStaticParagraph + 1) thru -1)
make new paragraph at after last paragraph with data myText
end tell
tell document 1 to save
open signatureFile
tell document 1 to activate
end tell
if application "Mail" is running then
tell application "Mail"
set signatureContents to (the content of signature (signatureName as text)) as text
set signatureContents to paragraphs 1 thru lastStaticParagraph of signatureContents
set signatureContents to signatureContents & myText
set astid to AppleScript's text item delimiters
set AppleScript's text item delimiters to "
"
tell signature (signatureName as text)
set its content to ""
set its content to its content & signatureContents
end tell
set AppleScript's text item delimiters to astid
end tell
end if
end if
Best Regards
McUsr
Something mysterious is formed, born in the silent void. Waiting
alone and unmoving, it is at once still and yet in constant motion. It is
the source of all programs. I do not know its name, so I will call it the
Tao of Programming.
If the Tao is great, then the operating system is great. If the
operating system is great, then the compiler is great. If the compiler is
greater, then the applications is great. The user is pleased and there is
harmony in the world.
The Tao of Programming flows far away and returns on the wind of
morning.
– Geoffrey James, “The Tao of Programming”