AppleScript for Mail.app : convert outgoing message to plain text

17 Views Asked by At

When I use AppleScript to make a new outgoing message in Mail.app, the message is always being set to rich text (which is a bit confusing as I have the app setup to use plain text by default.)

Script:

tell application "Mail"
    set newMessage to make new outgoing message
    tell newMessage
        set subject to "sub"
        set content to "body here" & return & return
        make new attachment with properties {file name:"/tmp/picture.jpg"} at after the last word of the last paragraph
        set sender to "[email protected]"
        set visible to true
    end tell
    activate
end tell
delay 0.9
tell application "System Events" to keystroke "t" using {command down, shift down}

Is there a clean way to set the message to be plain text? I seem to be missing something with DefaultMessageFormat.

Currently I use hacky keystroke seen above.

Note: the 0.9s delay is there because if I don't use this on Mojave (dark mode), the message will show dark grey text on a dark grey background :-(

0

There are 0 best solutions below