Da gibt es doch glatt keinen Apple-Script-Befehlt zum Erstellen einer reinen Text-Email unter Apple Mail. An dem Punkt setzt dann GUI-Scripting an, das ausführen, was noch die zuvor ein Skript in einem Programm ausgeführt hat...
Nun, das hier als einfaches Beispiel, wie man eine Email in Apple Mail via Skript erstellt und anschließend über GUI-Skripting die Email in reinen Text umwandelt ( der letzte Schritt funnktioniert nur in einem dt. OS, da nach dem Namen des Menüpunktes gesucht wird!).
--make new cc recipient at beginning of cc recipients ¬
--with properties {address:ccadresse}
endtell
endtell
endnew_mail
onswitch_to_reinen_text()
activateapplication "Mail"
tellapplication "System Events"
getsystem attribute "sysv"
ifresultisgreater thanorequal to 4144 then-- Mac OS X 10.3.0
ifUI elements enabledthen
tellapplication process "Mail"
if (nameofmenu item 11 ofmenu 1 ofmenu bar item 8 ofmenu bar 1) = "In reinen Text umwandeln" then
keystroke "t" usingshift down & command down
endif
endtell
else
beep
display dialog "GUI Scripting is not enabled" & return & return & "Open System Preferences and check Enable Access for Assistive Devices in the Universal Access preference pane, then run this script again." with iconstop
display dialog "This computer cannot run this script" & return & return & "The script uses GUI Scripting technology, which requires an upgrade to Mac OS X 10.3 Panther or newer." with iconcautionbuttons {"Quit"} default button "Quit"
Mail:Reine Text Email via Skript estellen
my new_mail("test_betreff", "keinevalideEmailAlsoGarNichtErstVersuchen@hubionmac.com", "Was ich schon immer mal schreibe wollte")
my switch_to_reinen_text()
on new_mail(email_betreff, toadresse, Mail_text)
tell application "Mail"
set newMessage to make new outgoing message with properties {subject:email_betreff as text}
tell newMessage
set visible to true
make new to recipient at beginning of to recipients ¬
with properties {address:toadresse}
set content to Mail_text
--make new cc recipient at beginning of cc recipients ¬
-- with properties {address:ccadresse}
end tell
end tell
end new_mail
on switch_to_reinen_text()
activate application "Mail"
tell application "System Events"
get system attribute "sysv"
if result is greater than or equal to 4144 then -- Mac OS X 10.3.0
if UI elements enabled then
tell application process "Mail"
if (name of menu item 11 of menu 1 of menu bar item 8 of menu bar 1) = "In reinen Text umwandeln" then
keystroke "t" using shift down & command down
end if
end tell
else
beep
display dialog "GUI Scripting is not enabled" & return & return & "Open System Preferences and check Enable Access for Assistive Devices in the Universal Access preference pane, then run this script again." with icon stop
if button returned of result is "OK" then
tell application "System Preferences"
activate
set current pane to pane "com.apple.preference.universalaccess"
end tell
end if
end if
else
beep
display dialog "This computer cannot run this script" & return & return & "The script uses GUI Scripting technology, which requires an upgrade to Mac OS X 10.3 Panther or newer." with icon caution buttons {"Quit"} default button "Quit"
end if
end tell
end switch_to_reinen_text