Im am using te applescript to send mails from my Mac from a shell script. The script runs fine with one exception: The 'standard' user setting "always Bcc myself" is not set again when the script ends... I am trying to do this with the boldface lines in the script. Switching off does work in the italic lines!

Is there a way to store ALL user settings and restore them at the end of the script?

-- 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 visible to false
        set sender to "email adress"
        set content to myMsgBody
        set subject to "pCloud 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
    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
  • I get what you mean, but the bold/italic markdown doesn't work within code blocks - it becomes literal. I expanded your code block to include the entire script - we'll just have to imagine the * sections are B/I.
    – Tetsujin
    Sep 7 at 15:45
  • Have you tried echoing what you've captured in the variables, make sure it's what you expect? [idk how this structure works in Mail so I can't help on specifics, sorry.]
    – Tetsujin
    Sep 7 at 15:47

1 Answer 1


I found what the problem was. "always bcc myself" and "always cc myself" are not independent. In fact it implemented as "always [xx] myself" as true or false, and "cc" and "bcc" as an option. The effect is that if the last in the script is false then auto copying is off. First testing the copied value before setting bach the orinal did the trick.

-- Set user's setting back to what it was
    --   Since only one of cc or bcc can be true, check first 
    --   before setting, else the last set will take preference
    -- bcc
    if Cpy_bcc_myself is true then
        set always bcc myself to true
    end if
    -- cc
    if Cpy_cc_myself is true then
        set always cc myself to true
    end if

You must log in to answer this question.

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