Title: Re: Looking for a script
On 5/2/02 5:10 AM, "John Boggs" <[EMAIL PROTECTED]> wrote:

> Yes Barry,
>
> I do have the ability to set the category on the message, and copying the
> category for the message to the new contact would be fine.  What I would
> really like to be able to do is something like this......
>
> RULE==========
>
> Any receipeint contains "uvcmembers.comm"
>
> Then.....
>
> Add Sender to Address Book
> Set Contact Category to "Client"
>
>
>
> Understand?????
>

That's easy to do by AppleScript, John., except I'm not sure that you really meant 'any recipient' part, the recipient of an email you receive is you. Did you perhaps mean

If

    <From>  contains "uvcmembers.comm"

? If so, set your Rule criteria however you want: you can have many alternate From senders, or easier, might be to keep adding them to a group. Then your criterion could be

if

     <From> is in group <Clients>

The Action would be to <Run AppleScript>, and run the following script, previously saved as a compiled script in the script folder:

---------------Contact Category of Sender--------------

property catname : "Client"

tell application "Microsoft Entourage"
    
    if not (exists category catname) then
        make new category with properties {name:catname}
        beep
        display dialog "A new " & catname & " category has just been made, and will be assigned to the sender." & return & return & "Set the color of the category later." with icon 2
    end if
    
    set theMsg to item 1 of (get current messages)
    set theSender to sender of theMsg
    set {eAddress, dName} to {address, display name} of theSender
    
    set theContacts to find eAddress
    
    if theContacts � {} then
        set theContact to item 1 of theContacts
        set theName to name of theContact
        beep
        display dialog "There is already a contact named " & theName & " with the same email address <" & eAddress & "> in the Address Book." & return & return & "Add another contact, or just set category of existing contact?" buttons {"Cancel", "New Contact", "Set Category"} with icon 2
        if button returned of result = "Cancel" then
            return
        else if button returned of result = "Set Category" then
            set theCategories to category of theContact
            if {category catname} is not in theCategories then
                set category of theContact to ({category catname} & theCategories)
            end if
            open theContact -- or cut this line
            return
        end if
    end if
    
    set AppleScript's text item delimiters to {" "}
    if (count (text items of dName)) > 1 then
        set lName to text item -1 of dName
        set fName to (text items 1 thru -2 of dName) as string
    else if dName � "" then
        set lName to dName
        set fName to ""
    else -- no display name
        set lName to eAddress
        set fName to ""
    end if
    set AppleScript's text item delimiters to {""}
    
    set newContact to make new contact with properties {first name:fName, last name:lName, email address:eAddress, category:{category catname}}
    open newContact -- or cut this line

    set category of theMsg to category catname
       
end tell

--------------------------------------

You could have a separate copy of the script if you want to do this with more than one category for different groups, and just change the name "Client" to another category in the top line of script.

--
Paul Berkowitz

Reply via email to