2001 - rule

  • Thread starter R. Alexander Seinfeld
  • Start date
R

R. Alexander Seinfeld

Is there a way to create a rule that will automatically add a recipient to
my address book if he is not already there?

(I created an anti-spam rule: if sender is not in address book then delete -
problem is if the sender is replying to a message from me - so I want an
outgoing rule that will add him to my address book. It seems to me that a
script might do this, but I don't understand scripting. Thanks)
 
B

Barry Wainwright [MVP]

Add recipients to address book is not available as an action to an outgoing
rule. It is quite possible to do it from an applescript though - do you have
any scripting experience? You can get a list of recipients from an outgoing
mail by script, then parse that list searching the address book for thier
email addresses and making a new contact for any that turn up as unique. (at
least, you can do all of this in vX & 2004, probably could do it in 2001 as
well, but I can't be certain of that)

If these basic pointers aren't enough, write back and I'll put a bit more
flesh on the bones.
 
R

R. Alexander Seinfeld

Thank you for all of your replies

I do not have scripting experience, please share.

I do note that the rules do allow me to identify an outgoing recipient as
"not in address book" so I can use that do activate a script. What do I have
to put in the script to make it create a new contact?
 
B

Barry Wainwright [MVP]

This script will do it:

property catName:"Auto-added Contact" -- Change this category name to
anything convenient
Property openContactAfterCreation: true -- change this to false if you don¹t
want the contacts oppened after creation
tell application "Microsoft Entourage"
try
set theCat to category catName
on error
set theCat to make new category with properties {name:catName,
color:{65280, 26112, 0}}
end try
set theMessages to current messages
repeat with aMessage in theMessages
set theRecipients to (get recipients of aMessage)
repeat with aRecipient in theRecipients
set {displayName, emailAddress} to {display name of address of
aRecipient, address of address of aRecipient}
find emailAddress
if the result is {} then
set theBreak to offset of " " in (reverse of characters of
displayName as text)
if theBreak > 0 then
set lastName to text -(theBreak - 1) thru -1 of
displayName
set firstName to text 1 thru -(theBreak + 1) of
displayName
else
set lastName to displayName
set firstName to ""
end if
set theContact to make new contact with properties {first
name:firstName, last name:lastName, category:{theCat}}
make new email address at end of theContact with properties
{contents:emailAddress}
if openContactAfterCreation open theContact
end if
end repeat
end repeat
end tell

It will operate either on a filtered outgoing message, or on any number of
selected outgoing or incoming messages, creating new contacts for any
recipients not found in the address book. It will also assign a category
"Auto-added contacts", coloured Orange (you can change this name in the
first line of the script) to these contacts and optionally open the contact
after creating it for you to examine the contents.

Save the script as a compiled script & put it in the ŒEntourage Script Menu
Items¹ folder in your ŒMicrosoft User Data¹ folder. The script can be
manually run from the menu or called as an action in a mail rule.
 
B

Barry Wainwright [MVP]

This script will do it:

[snip]

Oops ­ a typo crept in there, a few lines up from the bottom it should read:

if openContactAfterCreation then open theContact
 
R

R. Alexander Seinfeld

I really appreciate this.
I tried it but got an error message when it tried to run - "Error -192"

(script compiler had me add an extra "then" in the last clause, but that was
before running it)
 
B

Barry Wainwright [MVP]

The extra 'then was the subject of my following email! Sorry about that.

Error -192 usually indicates 'resource not found'. Does this happen on any
particular line?

If not, I will have to try and find a copy of entourage 2001 lying around to
see what is causing the problem.
 
B

Barry Wainwright [MVP]

OK, I installed office 2001 again!
(boy it sure looks ugly, but it is fast!)

The script runs just fine there, without any errors. What is probably
happening is that you are writing the script in a modern script editor which
saves the script in a data-fork format file. Office 2001 knows nothing about
data fork scripts. They were introduced long after Office 2001 was
superseded.

Unfortunately, there is no easy way to save a script in the old format now.
I have converted the script to the old format and uploaded it here:
<http://homepage.mac.com/barryw/temp/addRecipient.zip>

Download the script, unzip it then drop it into the script menu items folder
WITHOUT OPENING IT IN SCRIPT EDITOR.

That should work.

If you need to edit the script, I have a droplet utility on my web site that
will let you save a file in the modern data fork format and convert it to
the older resource fork format:
<http://homepage.mac.com/barryw/scripts/scripts.html>
(the script is the first one listed)
 
P

Paul Berkowitz

Unfortunately, there is no easy way to save a script in the old format now.

If you ever had OS 9 on your computer and - I think - even if you have
Classic installed, so the exception here would be only if you have a new Mac
Intel computer - you'll find an "Applications (Mac OS 9)" folder on the root
of your startup disk hard drive. Within that is an Apple Extras folder,
within that an AppleScript folder, and within that v1.8.3 of Script Editor.
It still saves scripts in the old Resource Fork format. So, as long as you
don't have an Intel Mac, this should be a solution, especially for Alexander
who must in be in Classic a lot of the time. Scripts saved in SE 1.8.3 will
work fine in Entourage 2001.

(Note: this whole issue only arises for scripts that have 'property'
declarations at the top and later reset the property to a new value, as
Barry's script does.)

--
Paul Berkowitz
MVP MacOffice
Entourage FAQ Page: <http://www.entourage.mvps.org/faq/index.html>
AppleScripts for Entourage: <http://macscripter.net/scriptbuilders/>

Please "Reply To Newsgroup" to reply to this message. Emails will be
ignored.

PLEASE always state which version of Microsoft Office you are using -
**2004**, X or 2001. It's often impossible to answer your questions
otherwise.
 
R

R. Alexander Seinfeld

Yay - it worked! Thanks to you Barry with Paul's assist. You're the best.
Whatever they pay you guys, it ain't enough. Thank you thank you thank
you...
 
B

Barry Wainwright [MVP]

(Note: this whole issue only arises for scripts that have 'property'
declarations at the top and later reset the property to a new value, as
Barry's script does.)

Not quite right in this case - I do declare two global properties, but I do
not change their values or try to re-store them. Properties were only used
to allow the values to be easily changed if the user wanted to use different
categories etc.

That certainly is a problem for users of Office vX, but in this case
Alexander was running Office 2001 which knows nothing at all about data fork
scripts - he was just getting a 'error -192' - "Resource not found".
 
Top