* "R" == Rik Kabel <rik(_at_)netcom(_dot_)com> writes:
T> Is there a easy way to detect number of recipients of a message? I.e. It
T> should detect there are 5 recipients in the following message:
T>
T>
T> From: Doe John <doe(_at_)some(_dot_)edu>
T> To: Person1 <person1(_at_)some(_dot_)com>, "Person2 LastName"
<person2(_at_)some(_dot_)edu>
T> cc: Person3 <person3(_at_)some(_dot_)com>,
T> Person4 <person4(_at_)some(_dot_)com>,
T> Person5 <person5(_at_)some(_dot_)com>
T> Subject: Re: Welcome to our list!
R> There is no easy way to reliably count the recipients. You can
R> reliably sum the number of to, cc, apparently-to, ... headers, and
R> you can count the number of commas in each and add that to the
R> total, but there are still problems.
R> You cannot rely on commas as a separator of addressee names because
R> there may be comments with commas which do not serve to separate
R> addressee names. Even if you remove comments (and please share your
R> method) there may be list names ( friends:; ) which may or may not
R> generate addresses. You cannot rely on @ for the same reasons,
R> along with the problem of local addresses with no @.
Your methods as well as Philip/David's recursive includerc does a
reasonable job for my task at hand, which is to sort messages with
large number of recipients to a different folder. I rarely get
messages with commas in comments and I do list/"friends:;"
detection/sorting before I need to count recipients.
R> Nonetheless, you can get a reasonable count (for some values of
R> reasonable) with something akin to this:
R> :0
R> * 1^1 ^((resent|apparently)-)?(to|b?cc):\/.*
R> * 1^1 MATCH ?? ,
R> { MAYBETO=$= }
R> (Note: this counts both resents and apparentlys. Both are rare, and
R> rarer still is to find both in the same message.)
R> This will count each of the selected headers, and will add in the
R> number commas in the last of those headers. If there are 2 To:
R> headers, the first of which has 100 addresses and the second of
R> which has 1 address (and no commas), this will score 2. If the
R> first has 1 address, and the second 100 addresses (and excatly 99
R> commas), this will score 101. On your example, it scores 4.
R> I'd love to see a relatively inexpensive, accurate recipe.
A little more accurate way is to use either your recipe or
Philip/David's recipe to count comma separated items in "To", "Cc",
"Resent-To" separately and sum them up as total number of
recipients. Still it doesn't handle well messages with multiple "To"
or "Cc" lines.
This is what I end up to use. And I packaged the recipes a bit so that
it returns total number of recipients. If anyone is interested, please
let me know.
Thanks for the help, everyone!
Tony