Apple script, insert email of group in mail

Discussion in 'Mac Programming' started by eric98, Nov 5, 2012.

  1. eric98 macrumors newbie

    Nov 5, 2012

    I tried to get the email adress of any persons of a group (in adress book) in a new outgoing message.

    Did some one have any idea how the apple script should look like?

    many thank's for your help
  2. kryten2 macrumors 6502a

    Mar 17, 2012
    An example of a Work group with 2 persons in it. Both of them with a work and home email address.

    set emailList to {}
    tell application "Address Book"
    	set thePersons to get every person of group "Work"
    	repeat with aPerson in thePersons
    		set end of emailList to the value of aPerson's email
    	end repeat
    end tell
    tell application "Mail"
    	set theMessage to make new outgoing message with properties {visible:true, sender:"", subject:"Testing", content:"Just testing Mail with Address Book"}
    	tell theMessage
    		repeat with anItem in emailList
    			repeat with anAddressItem in anItem
    				make new to recipient at end of to recipients with properties {address:anAddressItem}
    			end repeat
    		end repeat
    	end tell
    end tell

    Attached Files:

Share This Page