applescript

Populate Cc field using AppleScript


Following syntax generates email message in apple mail addressed "To" a recipient. Requesting guidance on how to populate the Cc field with 3 additional email addresses. Thanks.

tell application "Mail"
set theNewMessage to make new outgoing message with properties {visible:true, subject:"Update", content:"Hi, Tom. 

All set:
… on the server.

thx. 

-paul."}

tell theNewMessage
    make new to recipient at end of to recipients with properties {address:”tom@zepoffice.com"}
    activate
end tell
   end tell

Solution

  • It took me a while. I have this worked out. I define the sender. I also define the main recipient + 3 cc recipients.

    set the_subject to "Update"
    set the_body to "Hi, Luciano. 
    
    All set:
    … on the server.
    
    thx. 
    
    -lucca."
    
    tell application "Mail"
    
    
    set new_message to make new outgoing message ¬
        with properties {sender:"MyName  <MyEmail@mac.com>", 
    subject:the_subject, content:the_body, visible:true}
    
    
    tell new_message
        -- Add the recipients:
        make new to recipient ¬
            at end of to recipients ¬
            with properties {address:"person0@mac.com"}
        make new cc recipient ¬
            at end of cc recipients ¬
            with properties {address:"person1@mac.com"}
        make new cc recipient ¬
            at end of cc recipients ¬
            with properties {address:"person2@mac.com"}
        make new cc recipient ¬
            at end of cc recipients ¬
            with properties {address:"person3@mac.com"}
        
        end tell
        end tell