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

SouthernAtHeart

macrumors newbie
Original poster
Nov 6, 2011
28
0
I'm trying to move any person in a specified group to the group "test2" if they have an email address, but can't quite get it...
Code:
repeat with theContact in people in the group named theirGroup
		if (the email of theContact is not missing) then			
			add theContact to group "test2"
			save
		end if
	end repeat
I must be close?
 
I assume your scripting the Mail app ?

Also you need to post more of the Applescript's code, in order for someone
to help you with the code.

But I think your line.

Code:
(the email of theContact is not missing)

Should probably be.

Code:
(the email of theContact is not missing value)

But I am only guessing with out the rest of the script's code.

Regards Mark
 
Code to find contacts with email

Code:
tell application "Address Book"
    repeat with theContact in people in the group named "test1"
        repeat with emailID in emails of theContact
            add theContact to the group "test2"
        end repeat
    end repeat
end tell

I am trying to figure out how to add contacts in one group that have an email address into another group.
This code doesn't work yet. I've tried numerous things. :(
Thanks for the help.
 
When you get the email [addresses] of a person, the result is a list of those emails. Even if there are no emails, the result will still be a list (although an empty one), so your script would be something like:

Code:
tell application "Address Book"
	repeat with theContact in (people in group "test1")
		if (email of theContact is not {}) then
			add theContact to group "test2"
			save
		end if
	end repeat
end tell

Also be careful about using class or property names as commands. If you are wanting to use a filter reference form, you can use something like (groups whose name is "test") - note that this will also be a list.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.