3

I am trying to use AppleScript to automate sending mails through AppleMail, but the message always ends up being send as a blockquote (i.e. as if I replied to an email and my message got quoted). Is there something I might be doing wrong, or is this a bug in AppleMail?

To clarify, if I try to send the message "Hello you", it is being sent as a rich text email with the plain text version

> Hello you

and the html version has

<blockquote>Hello you</blockquote>

in it...

Interestingly the blockquote in Apple Mail looks like normal text, so I only spotted the issue after looking at the raw message source...

The script that I use looks like this:

tell application "Mail"
    set this_message to make new outgoing message
    
    tell this_message
        set subject to "AppleScript Test Email"
        set content to "This is the body of the test email"
        make new to recipient at beginning of every to recipient ¬
            with properties {address:"[email protected]"}
    end tell
    
    send this_message
end tell
3
  • I cannot reproduce. The text appears normally.
    – Thinkr
    Oct 15, 2023 at 9:55
  • @Thinkr did you look at the raw source of the message or just how it is displayed by Mail.app? The "> " are only in the plain text part and Mail seems to render its "blockquote" of the formatted part as if it was normal text... (press cmd+option+U for the raw source) If you look at the mail in Thunderbird or another client and tell it to show the plain text version you will see that the whole mail is shown as a quote (like a reply without added text)...
    – powerpete
    Oct 15, 2023 at 10:57
  • 1
    Oh, sorry. I can now confirm :)
    – Thinkr
    Oct 15, 2023 at 11:26

1 Answer 1

0

You cannot adjust the original body of an email after it is created. To do what you want, you need to provide the text in the same command that creates the message. This is done using the content property.

You should be able to include the subject in the same command but if it doesn't work this way, try adding it separately after. I think this development is part of apple's ongoing security efforts.

set bodyText to "This is the body of the test email"
set subjectText to "AppleScript Test Email"

tell application "Mail"
    set this_message to make new outgoing message with properties {content:bodyText, subject:subjectText}
end tell

BTW, there might be a preference that determines whether quoted text gets the > or not.

1
  • Thank you, but actually setting the content after creating it did work for me. I now tried your version, but the content is still prefixed with ">"... The problem is that the text is not actually quoted text, it is the original text.... I.e. there is no way to create a message without the ">" before each line. I did try my script in an older version of Apple Mail and there it works... Maybe it is just a bug in Apple Mail?!
    – powerpete
    Oct 14, 2023 at 12:30

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .