Using AppleScript to set a mail message to Plain Text

前端 未结 3 1542
忘掉有多难
忘掉有多难 2021-01-20 06:45

I have an AppleScript that nicely collates information and creates an email message with attachments.

I cannot find a way for the script to set the message format to

3条回答
  •  失恋的感觉
    2021-01-20 07:40

    I found this question while trying to solve exactly this problem. Eventually I came up with the following solution:

    tell application "Mail"
        set newMessage to make new outgoing message 
            with properties {visible:true,
                             subject:"message title",
                             sender:"sender@from.address",
                             content:mailBody}
        tell newMessage
            make new to recipient with properties {address:"mail@recipient.com"}
        end tell
        activate
    end tell
    
    tell application "System Events"
        click menu item "Make Plain Text" of ((process "Mail")'s (menu bar 1)'s (menu bar item "Format")'s (menu 1))
    end tell
    

    Hopefully someone will find this useful, I know I would have several hours ago!

    This is tested on Mail versions 7.3 and 12.4. Newer, or older, versions might need different menu titles.

提交回复
热议问题