Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

eric98

macrumors newbie
Original poster
Nov 5, 2012
1
0
Hi,

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
 

kryten2

macrumors 65816
Mar 17, 2012
1,114
99
Belgium
An example of a Work group with 2 persons in it. Both of them with a work and home email address.

Code:
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:"me.somewhere@rainbow.com", 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
 

Attachments

  • Picture 1.png
    Picture 1.png
    61.5 KB · Views: 90
  • Picture 2.png
    Picture 2.png
    61.5 KB · Views: 84
  • Picture 7.png
    Picture 7.png
    32.7 KB · Views: 97
  • Picture 8.png
    Picture 8.png
    32.3 KB · Views: 95
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.