Title: Re: Way to check for duplicate emails addresses in a message?
That’s it! Whatever you did to this modified script makes it work brilliantly.

I first tested it by tossing in the same group of 40 twice, which brought the number of emails to 80. I then ran the script, and voila, in less than 2 seconds, it brought the number of emails back down to 40.

I’ve been smoking it up and down, and I’ve found I can even place a group with groups in it. I can also place a group in all 3 To’s (To, CC, and BCC), and it will still calculate all of them to find the duplicates. I’ve even tested the results afterwards by copy/pasting all the names into a Word doc, separating each name into its own paragraph, and then doing a Sort, to see if there are any dupes left.  

I think this is going to be one of the most powerful, useful scripts. Think about it: one of the handiest features of Erage is the ability to give each Record multiple categories (some one is a “Friend” but also a “Local Biz” and a “Customer”). Before this script, there was always the possibility of sending that person 3 of the exact emails each time you did a large e-mailing. If the email contains a 1 Meg file (the exact situation that created the initial inquiry for this script), you can anger a lot of your family and associates. As our e-address book grows (hey, think of 10 years from now), this duplicate sending would become more and more the norm.

Very powerful. Many thanks.  

Scott
<[EMAIL PROTECTED]>

_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/

From: Paul Berkowitz <[EMAIL PROTECTED]>
Date: Sun, 28 Jan 2001 18:15:33 -0800
To: "R. Scott Ohlgren" <[EMAIL PROTECTED]>
Subject: Re: Way to check for duplicate emails addresses in a message?


On 1/28/01 5:09 PM, "R. Scott Ohlgren" <[EMAIL PROTECTED]> wrote:

I'm getting a “No result was returned from some part of this expression” error message when I run the Remove Duplicate Recipients script.

I think I see what it might be. Do you have any groups made by my Category Group script, or another one (no way to do this except by script) which gives you group members without email addresses?

If that's the case, try this fixed script below.

If not, open  the script in Smile or Script Editor, and run it from there with a suitable new message window open in the front window of Entourage. (Arrange the new message first, with the same recipients as when it errored before. Leave it in the front of E, then click into your script editor and run the script.) Tell me which words in which line of the script get highlighted when the same error message is clicked OK. That error message is too vague without doing this for me to know where the problem lies.




------Fixed Script-----------------------

global ods

tell application "Microsoft Entourage"
    
    set theDraft to window 1
    if class of theDraftdraft window then
       beep
       display dialog "You must have your new message window [not the Address Book, a Custom View, or anything else] in the front when you run the script." buttons {"OK"} default button "OK" with icon 0
        return
   end if
   set {theTo, theCC, theBCC} to theDraft's {to recipients, CC recipients, BCC recipients}
    set {ods, AppleScript's text item delimiters} to {AppleScript's text item delimiters, {", "}}
    set {toList, ccList, bccList} to {text items of theTo, text items of theCC, text items of theBCC}
    set AppleScript's text item delimiters to ods
   
    set toList to my ResetRecipients(toList, {}, {})
    set ccList to my ResetRecipients(ccList, toList, {})
    set bccList to my ResetRecipients(bccList, ccList, toList)
    set AppleScript's text item delimiters to {", "}
    set {window 1's to recipients, window 1's CC recipients, window 1's BCC recipients} to {"" & toList, "" & ccList, "" & bccList}
    set AppleScript's text item delimiters to ods
   
end tell


on ResetRecipients(theList, previousList, anteriorList)
    
    tell application "Microsoft Entourage"
        
        set newList to {}
        if theList � {""} then
           repeat with i from 1 to (count theList)
                set aRecip to item i of theList
               if aRecip does not contain "@" then --
must be group
                   
                    set newList to my ProcessGroup(aRecip, theList, previousList, anteriorList, newList)
                    
                else --
it's a contact
                   
                    set AppleScript's text item delimiters to {" <"}
                    try
                       set dName to text item 1 of aRecip
                       set eAddress to text 1 thru -2 of text item 2 of aRecip --
remove final ">"
                       
                        set AppleScript's text item delimiters to ods
                       
                        if (eAddress = default email address of contact dName) then
                           if ({dName} is not in newList) and ({dName} is not in previousList) and ({dName} is not in anteriorList) then set end of newList to dName --
will be contact icon
                           
                        else --
more than one contact with that name or not using default email address
                           if ({aRecip} is not in newList) and ({aRecip} is not in previousList) and ({aRecip} is not in anteriorList) then set end of newList to aRecip -- use @ format
                           
                        end if
                   on error --
address only    
                       set AppleScript's text item delimiters to ods
                       if ({aRecip} is not in newList) and ({aRecip} is not in previousList) and ({aRecip} is not in anteriorList) then set end of newList to aRecip --
address only, @ format
                   end try
               end if
           end repeat
           
        else
           set newList to {""}
        end if
   end tell
   return newList
   
    
end ResetRecipients


to ProcessGroup(aRecip, theList, previousList, anteriorList, newList)
    
    
    tell application "Microsoft Entourage"
        
        try
           set theGroup to group aRecip
       on error --
if actually an artificial group member without email address
           return newList
       end try
       set theEntries to content of every group entry of theGroup
       
        repeat with j from 1 to (count theEntries)
            
            set anEntry to item j of theEntries
           
            repeat 1 times --
for doing next repeat after  nested groups
               
                try
                   set {dName, eAddress} to {display name, address} of anEntry
                   if eAddress = "" then
                       set newList to my ProcessGroup(dName, theList, previousList, anteriorList, newList) --
recursive
                       exit repeat -- the 1 times repeat, go on to next group entry
                   end if
                   if dName � "" then
                       if dName starts with "\"" then set dName to text 2 thru -2 of dName --
equivalent to display name without quotes
                       if eAddress = default email address of contact dName then
                           if ({dName} is not in newList) and ({dName} is not in previousList) and ({dName} is not in anteriorList) then set end of newList to dName --
will have contact icon
                           
                        else --
more than one contact with that name or not using default email address
                           set nameAddress to dName & " <" & eAddress & ">"
                            if ({nameAddress} is not in newList) and ({nameAddress} is not in previousList) and ({nameAddress} is not in anteriorList) then set end of newList to nameAddress --
use @ format
                       end if
                       
                    else --
no display name, address only
                       if ({eAddress} is not in newList) and ({eAddress} is not in previousList) and ({eAddress} is not in anteriorList) then set end of newList to eAddress -- will have @ format
                   end if
               on error
                   exit repeat --
the 1 times    repeat, move on to next group entry
               end try
           end repeat --
the 1 times repeat
           
        end repeat
       
    end tell
   
    return newList
   
end ProcessGroup



------------end script---------------
--
Paul Berkowitz


Reply via email to