|
|
#1 |
|
Prospect
Join Date: Apr 2008
Posts: 5
|
Mail.app AppleScript
I'd been searching for a way to import/export my collection of 350 (and growing) signatures in and out of Mail.app. I finally found a set of AppleScripts here (specifically the last two at the bottom of the thread):
http://www.macosxhints.com/article.p...21103060644193 The export script works fine, creating a text file with all of my signatures. The import script doesn't - I've tried doing some troubleshooting by stripping it down to just this: set sigText to "Test" set signame to "Test" tell application "Mail" make new signature with properties {name:signame as text, content:sigText} end tell The script runs, outputting this to the Result window: signature "Test" of application "Mail" If I then go to the Mail.app Preferences/Signatures, I can see a new "Test" signature in the "All Signatures" list, and the total number of signatures has incremented by one. However, the Preferences window seems to freeze at that point - all clicks within it are ignored. If I Quit out of Mail.app and restart, the "Test" signature is gone (the total count has also dropped back down by one). Is this a problem with the current version of Mail.app (the original thread with these scripts is several years old)? Is there another/better way to do this? Seems like this should be such a simple task. I'm a complete AppleScript newbie. Help? |
|
|
|
|
|
#2 |
|
Hall of Famer
Join Date: Apr 2007
Posts: 4,263
|
this has been a long-standing issue with Mail (at least a year old...). let me play with it a bit and see if there's a workaround.
__________________
Philosophy is a battle against the bewitchment of our intelligence by means of language. -LW- |
|
|
|
|
|
#3 |
|
Prospect
Join Date: Apr 2008
Posts: 5
|
Thanks - as a switcher (almost two years now), I'm pretty happy with Mail but can't believe there doesn't seem to be any signature management software apart from what's offered in the Preferences.
|
|
|
|
|
|
#4 |
|
Hall of Famer
Join Date: Jan 2002
Posts: 3,541
|
Signatures, at least in Leopard's Mail.app, are stored .webarchive files inside the ~/Library/Mail/Signatures folder. They're not straight text files, but they can be opened in Safari. You could script Safari to open them, ask Safari for the document text, and then do with that text what you wish.
__________________
COMPUTER TYPE SOME SPECIFICATIONS I COPIED FROM THE BOX STUFF I INSTALLED ALL BY MYSELF "WITTY QUOTE" |
|
|
|
|
|
#5 |
|
Prospect
Join Date: Apr 2008
Posts: 5
|
You're right, I can open the individual signature files in Safari - but my problem isn't *exporting* the signatures (the script I'd found for that works fine), it's *importing* new ones. Scripting through Safari still might work, I suppose, but does anyone have any idea how the naming scheme for the individual .webarchive signature files works (if it matters), or how to update Mail's index (assuming it keeps one)?
|
|
|
|
|
|
#6 |
|
Hall of Famer
Join Date: Apr 2007
Posts: 4,263
|
you can actually use TextEdit to make webarchive files, so it might be possible to create all your signatures by scripting that. but then you'd have to monkey with the UUIDs and such in the signature plist file. it might be just easier to GUI script Mail.
__________________
Philosophy is a battle against the bewitchment of our intelligence by means of language. -LW- |
|
|
|
|
|
#7 |
|
Hall of Famer
Join Date: Jan 2002
Posts: 3,541
|
Oh, d'oh. I missed the "import" concept somehow. I suck at the forums today.
Agreed with tw here. I usually avoid GUI scripting like NYC subway rats, but it may be the easiest solution overall.
__________________
COMPUTER TYPE SOME SPECIFICATIONS I COPIED FROM THE BOX STUFF I INSTALLED ALL BY MYSELF "WITTY QUOTE" |
|
|
|
|
|
#8 |
|
MVP
Join Date: Apr 2004
Location: Hello London Calling
Posts: 1,787
|
Well I can help converting the Text or rtf file into webarchives.
Convert from rtf ( or you can change to txt ) Code:
tell application "Finder" set sourcePath to (choose folder with prompt "Please select the source directory") set sig_webAs to (items of folder sourcePath whose name extension is "rtf") as alias list end tell repeat with i from 1 to number of items in sig_webAs set this_item to POSIX path of item i of sig_webAs tell application "System Events" set sig_xml to do shell script "Textutil -convert webarchive " & quoted form of this_item log sig_xml end tell end repeat Convert from webarchive to rtf or .... Code:
tell application "Finder" set sourcePath to "Macintosh HD:Users:UserName:Library:Mail:Signatures" as alias set sig_webAs to (items of folder sourcePath whose name extension is "webarchive") as alias list end tell repeat with i from 1 to number of items in sig_webAs set this_item to POSIX path of item i of sig_webAs tell application "System Events" set sig_xml to do shell script "Textutil -convert rtf " & quoted form of this_item log sig_xml end tell end repeat Also I have not had time to test the import, but you should note the is a "SignaturesByAccount.plist" file that may also need updating
__________________
MH. |
|
|
|
|
|
#9 |
|
MVP
Join Date: Apr 2004
Location: Hello London Calling
Posts: 1,787
|
For future reference,
I have a posted a hint on the main site, which takes the idea in my last post to the next step, of actually fully importing/exporting your Rtf files (or other formats), Straight into/out of the Mail.app Signatures. Another take on exporting and importing Mail signatures
__________________
MH. |
|
|
|
![]() |
|
|