从 applescript 调用的 MacOS Mail 窗口闪烁,如何缓解

从 applescript 调用的 MacOS Mail 窗口闪烁,如何缓解

我有一个 applescript,它会将邮件发送给文件中设置的收件人,邮件正文位于另一个文件中。当我启动时,要发送的消息会在屏幕上的一个窗口中闪烁。我怎样才能使执行过程“不可见”?

这是我当前的脚本:

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 protected]>"
        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

相关内容