Go Back   MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Feb 2, 2012, 10:49 AM   #1
SouthernAtHeart
macrumors newbie
 
Join Date: Nov 2011
simple applescript email question

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?
SouthernAtHeart is offline   0 Reply With Quote
Old Feb 3, 2012, 03:15 PM   #2
Mark FX
macrumors member
 
Join Date: Nov 2011
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
Mark FX is offline   0 Reply With Quote
Old Feb 3, 2012, 05:13 PM   #3
SouthernAtHeart
Thread Starter
macrumors newbie
 
Join Date: Nov 2011
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.
SouthernAtHeart is offline   0 Reply With Quote
Old Feb 3, 2012, 07:31 PM   #4
Red Menace
macrumors 6502
 
Join Date: May 2011
Location: Littleton, Colorado, USA
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.
__________________
MacBook Pro / OS X Yosemite (10.10) / Xcode 6.1 / RubyMotion FTW
Red Menace is offline   0 Reply With Quote
Old Feb 3, 2012, 08:13 PM   #5
SouthernAtHeart
Thread Starter
macrumors newbie
 
Join Date: Nov 2011
Thanks

Thanks also for that other tip.
SouthernAtHeart is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
thread Thread Starter Forum Replies Last Post
Help needed for simple Applescript duckdealer Mac Programming 2 Apr 7, 2014 11:54 PM
Simple AppleScript for mail.app JosCiv OS X 0 Jul 26, 2013 12:32 PM
Simple applescript question Pecans Mac Programming 2 Jun 6, 2013 03:58 AM
Why doesn't this simple applescript work any more in ML mail.app (as a rule) wesleyh Mac Programming 0 Jan 26, 2013 10:25 AM
looking for a simple code in automator or applescript for copy and paste duran118 Mac Applications and Mac App Store 0 Jul 25, 2012 02:24 AM

Forum Jump

All times are GMT -5. The time now is 09:30 AM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC