Title: Re: Script to delete from "recently  used address list"
On 7/14/05 9:19 AM, "Remo Del Bello" <[EMAIL PROTECTED]> wrote:

On 7/13/05 5:23 PM, Douglas Christopherson deftly typed out:

> Is there a script to simplify this procedure.

In case what you actually wanted to do was remove just one entry from the recent addresses list, AND you have a message from that person around, this script should do that for you:

tell application "Microsoft Entourage"
    set junkCat to category "Junk"
    set prevDelims to AppleScript's text item delimiters
   set AppleScript's text item delimiters to {" "}
    set theMessage to item 1 of (get current messages)
    set fullname to display name of sender of theMessage
   set eAddress to address of sender of theMessage
   set firstname to words 1 thru -2 of fullname
   set lastname to word -1 of fullname
   set AppleScript's text item delimiters to prevDelims
   set person to make new contact with properties {first name:firstname, last name:lastname, address:eAddress, category:junkCat}
    delete person
end tell

-Remo Del Bello


You're not using text items, so why are you setting text item delimiters in the first place? You're using "words", and firstname will be a list of words, not text.  Since various types of punctuation and certain other characters are considered by AppleScript to be word separators, using "words" could lead you into trouble, even if you coerced firstname to text.  You might well end up with a contact whose name does not correspond with the sender's. (E.g. "George C. Spammer, Inc." will end up as "George C Spammer Inc" . At the moment, you ought to be getting an error when you try to set first name to a list, but perhaps Entourage coerces it to text for you) Frankly, you would be better off using "text items", NOT "words". Probably you've seen no problem since Entourage actually just cares about the email address, not the display name, for Junk filtering: the name is not relevant (And I'm not sure that you really need to both set its category to Junk AND delete the contact – either one should work.) Still, you might as well get it right:


tell application "Microsoft Entourage"
    set junkCat to category "Junk"
    set prevDelims to AppleScript's text item delimiters
   set AppleScript's text item delimiters to {" "}
    set theMessage to item 1 of (get current messages)
    set fullName to display name of sender of theMessage
   set eAddress to address of sender of theMessage
   try -- there may be only one name
       set firstname to (text items 1 thru -2 of fullName) as Unicode text
   on error
       set firstname to ""
    end try
   set lastname to text item -1 of fullName
   set AppleScript's text item delimiters to prevDelims
   set person to make new contact with properties {first name:firstname, last name:lastname, address:eAddress, category:junkCat}
    delete person
end tell




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

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

Reply via email to