On or near 8/7/03 4:38 PM, Michael Scheurer at [EMAIL PROTECTED]
observed:
> on 8/8/03 8:58 AM, Paul Berkowitz wrote:
>
>> That all depends what you inserted for "--Do stuff here". Allan left that
>> for you to work out for yourself. I later provided a rather detailed version
>> (two versions, in fact
>> ) for you to use. What did you insert?
>
> Haven't worked out how to change the email address (what would the syntax
> for changing an existing email address?), however here is what I got:
>
> tell application "Microsoft Entourage"
> set ourStaff to every contact whose email address contains "@acme.com.au"
> repeat with aContact in ourStaff
> set company of aContact to "Acmes New Name"
> end repeat
> end tell
>
> This runs, but changes nothing, no errors either.
>
> whilst this works:
>
> tell application "Microsoft Entourage"
> set ourStaff to every contact whose company contains "Acme Widgets"
> repeat with aContact in ourStaff
> set company of aContact to "Acmes New Name"
> end repeat
> end tell
>
What you probably want to look at is "default email address", not "email
address." "Email address" is really an element, not a property, and a
contact can (as you no doubt know) have several. If you try this, you would
think it would also work:
set emailList to every email address of aContact
if emailList contains "@acme.com.au" then...
But to use that you would need to loop thru the contacts one at a time
rather than using "whose". And furthermore, when you check a list with
"contains" the item has to match exactly, so this would still fail. You
would need a sub-loop thru each address in the list:
repeat with anAddr in emailList
if anAddr contains "@acme.com.au" then...
-- do whatever
end if
end repeat
I started to work out a better way. But Script Debugger crashed. So let me
summarize. General idea is, instead of trying to use a whose clause with the
e-mail address field, which won't work, just get matching lists of contacts
and their addresses, and loop through those. Consider the code that follows
as an approximation; I have not run this in the script editor, although I
had a working version before the crash:
tell application "microsoft entourage"
set everyone to every contact
set allAddrs to email addresses of every contact
repeat with I from 1 to (count allAddrs)
set addrSet to item I of allAddrs
repeat with oneAddr in addrSet
if oneAddr ends with "@acme.widgets.com"
set theContact to item I of everyone
-- Do stuff to the identified contact
end if
end repeat
end repeat
end tell
Or, you could just loop thru the contacts:
tell application "microsoft entourage"
set everyone to every contact
repeat with I from 1 to (count everyone)
set theContact to item I of everyone
set addrSet to email addresses of theContact
repeat with oneAddr in addrSet
if oneAddr ends with "@acme.widgets.com"
-- Do stuff to the identified contact
end if
end repeat
end repeat
end tell
That might be faster, since it only does one operation involving all
contacts. On the other hand, it does individual accesses to get the e-mail
addresses of each contact, which could take longer than the first method.
You could try it to see which is more efficient...
--
Microsoft MVP for Entourage/OE/Word (MVPs are volunteers)
Allen Watson <[EMAIL PROTECTED]> Entourage FAQ site:
<http://www.entourage.mvps.org/>
AppleScripts for Outlook Express and Entourage:
<http://members.thinkaccess.net/[EMAIL PROTECTED]/Scripts/>
Entourage Help Pages: <http://www.entourage.mvps.org/>
--
To unsubscribe:
<mailto:[EMAIL PROTECTED]>
archives:
<http://www.mail-archive.com/entourage-talk%40lists.letterrip.com/>
old-archive:
<http://www.mail-archive.com/entourage-talk%40lists.boingo.com/>