I'm currently using the below script to send out an email with a specified subject, attachment, and body message:

on run argv
    set theSubject to (item 1 of argv)
    set theAttachmentFile to (item 2 of argv)
    set theContent to (item 3 of argv)

    tell application "Mail"

        set theAddress to {"[email protected]"} -- the receiver 
        set theSignatureName to "Test" -- the signature name    

        set msg to make new outgoing message with properties {subject:theSubject, content:theContent, visible:true}

        tell msg
            repeat with i from 1 to count theAddress
                make new to recipient at end of every to recipient with properties {address:item i of theAddress}
            end repeat
        end tell
        tell msg to make new attachment with properties {file name:theAttachmentFile as alias}

        set message signature of msg to signature theSignatureName

        send msg
    end tell
end run

I have been executing the script in the Mac Terminal using:

osascript /Users/dwm8/Desktop/email.scpt "Test" "dwm8:test.pdf" "Test Message Here"

However, I would like to make a small change in regards to the body message of the email I send out. Instead of sending out the message

Test Message Here

I would like the body of the email to say

Test Message Here

where I am able to specify where I want a line break. Does anyone know how I can implement this into my existing script? Thanks for the help!

1 Answer 1


If you interactively type the message, then your shell should allow you to continue a string on a newline, as long as you don't close the quote.

For example, type this and the outgoing message will have three lines.

osascript /Users/dwm8/Desktop/email.scpt "Test" "dwm8:test.pdf" "Test
> Message
> Here"

You can do the same thing in a .sh script,

osascript /Users/dwm8/Desktop/email.scpt "Test" "dwm8:test.pdf" "Test
  • Unfortunately, the message is previously written and is being passed through automatically. Is there any way to, say, replace each space in my string with a line break?
    – dwm8
    Nov 10, 2015 at 15:27

You must log in to answer this question.

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