You are not logged in.
This handler allows you to apply stationery to the front message in Mail. It will work in 10.5, 10.6 or 10.7. Note that if the email message has text then that text is automatically applied to the stationery. Therefore, you could create an applescript workflow to generate the email message and apply some stationery for a one-stop solution to create an awesome email.
In this example, open a new message in Mail (add some text to it if you like) and run this code. It will apply the "Gift" stationery from the "Birthday" category.
Applescript:
-- this will select a stationery for the front Mail window
-- to use you must first create a new email message in Mail
-- if you add text and images to the new mail message first, then when a template is chosen that information is automatically put into the template
set stationeryCategory to "Birthday"
set stationeryName to "Gift"
chooseMailStationery(stationeryCategory, stationeryName)
on chooseMailStationery(stationeryCategory, stationeryName)
-- this requires "access for assistive devices" to be checked in the "Universal Access" system preference pane
-- this will work on MacOSX 10.5 through 10.7
-- stationeryCategory is the category name containing the stationery to choose
-- stationeryName is the name of the stationery to choose, set it to false if you want a random stationery to be chosen
set shortDelay to 0.2
-- determine the OS version and set the proper section numbers accordingly
set sysVersion to the system version of (system info)
if sysVersion begins with "10.5" then
set categorySectionNumber to 5
set templatesSectionNumber to 6
else -- 10.6 or 10.7
set categorySectionNumber to 4
set templatesSectionNumber to 5
end if
tell application "Mail" to activate
delay shortDelay
tell application "System Events"
tell process "Mail"
tell window 1
-- show the stationery
if exists button "Show Stationery" of tool bar 1 then click button "Show Stationery" of tool bar 1
delay shortDelay
-- select the stationeryCategory
set categorySection to table 1 of scroll area categorySectionNumber
set categoryList to the value of static text of every row of categorySection
repeat with i from 1 to the count of categoryList
set thisCategory to item 1 of (item i of categoryList)
if thisCategory is stationeryCategory then exit repeat
end repeat
select row i of categorySection
delay shortDelay
-- select the stationeryName
set templatesSection to radio group 1 of scroll area templatesSectionNumber
if stationeryName is false then -- we pick a random template
set templatesButtons to name of buttons of templatesSection
set templateButton to some item of templatesButtons
else
set templateButton to stationeryName
end if
click button templateButton of templatesSection
delay shortDelay
-- hide the stationery
if exists button "Hide Stationery" of tool bar 1 then click button "Hide Stationery" of tool bar 1
end tell
end tell
end tell
end chooseMailStationery
Offline
I've tried this script and can't get it to work.
I'm on Lion OS 10.7.2 and when looking at the mail message interface quite a few things are not what the script uses:
No longer radio button for templates but rows in a table, scroll area for this is 6 when the script makes it 5, (could manage these) but more difficult is that there are no refs to buttons to pick the templates...(UI browser just can't identify what's in this area).
And I end up with this error message:
error "Erreur dans System Events : Il est impossible d’obtenir button \"Adret-envoi2010_07\" of table 1 of scroll area 6 of window \"Nouveau message\" of application process \"Mail\"." number -1728 from button "Adret-envoi2010_07" of table 1 of scroll area 6 of window "Nouveau message" of application process "Mail"
http://www.flickr.com/photos/33469248@N05/6335184286/
Offline
This still works for me running 10.7.3 and Mail version 5.2. Note that the script tells you that you must first open a new email message before running the script. If you don't do that then errors occur.
Offline