0

I have an applescript which mails to recepeints set in a file, with the body in another file. When I start the message to be sent flashes in a window on the screen. How can I make the execution 'invisable'?

This is my current script:

set myMsgBody to read "..../File1.txt" as «class utf8»
set myToRecipients to read "..../File2.txt" as «class utf8»

-- convert muliple lines in file into list
set ToRecipients to {}
repeat with e in paragraphs of myToRecipients
    if length of e is greater than 10 then
        copy e to the end of the ToRecipients
    end if
end repeat

-- send mail
tell application "Mail"
    
    -- Save user settings
    copy always bcc myself to Cpy_bcc_myself
    copy always cc myself to Cpy_cc_myself
    -- Make sure we don't get unexpected behaviour
    set always bcc myself to false
    set always cc myself to false
    
    -- Create message
    tell (make new outgoing message)
        set sender to "XXX <Email@domain.nl>"
        set content to myMsgBody
        set subject to "XXX wijzigingen"
        repeat with thisRecipient in ToRecipients as list
            make new to recipient at end of to recipients with properties {address:thisRecipient}
        end repeat
        -- Message ready, send it
        send
    end tell
    
    -- Set user's setting back to what it was
    set always bcc myself to Cpy_bcc_myself
    set always cc myself to Cpy_cc_myself
end tell
Tetsujin
  • 47,296
  • 8
  • 108
  • 135
Rob
  • 1
  • 1

0 Answers0