procmail
[Top] [All Lists]

Re: Atache a number to each email

1996-02-13 14:02:13
Philip Guenther <guenther(_at_)gac(_dot_)edu> wrote:
jzc(_at_)sibs(_dot_)com writes:
When autorespond to emails received, is there anyway to atache a 
consecutive number to it? Say:
1. For the first email received on 02/12/96, Procmail responds with:

Email number: 02129601
Other autoreply text.

2. For the second email received on 02/12/96, Procmail responds with:

Email number: 02129602
Other autoreply text.

How about this?

Either that, or use some more of procmail's available internal calculatory
capabilities...

Beware, untested:

--------------------daily cron job run at midnight---------
#!/bin/sh

cd $HOME

echo "DATE=`date +%d%e%y`
COUNT=000" >.procmail.count.$$

mv .procmail.count.$$ .procmail.count
------------------------cut here---------------------------

:0
* Conditions for doing autoresponder go here (See "man procmailex")
{
   STATEFILE=$HOME/.procmail.count
   INCLUDERC=$STATEFILE

   :0
   * $ $COUNT^0
   * 1^0
   { }

   NEWCOUNT=$=

   :0
   * NEWCOUNT ?? ^.$
   { NEWCOUNT=00$NEWCOUNT }

   :0
   * NEWCOUNT ?? ^..$
   { NEWCOUNT=0$NEWCOUNT }

   NEWCOUNT=`echo "DATE=$DATE
                   COUNT=$NEWCOUNT" >$STATEFILE.$$;
             mv $STATEFILE.$$ $STATEFILE`

   NEWCOUNT

   #
   # Now $DATE$COUNT should have the desired value
   #
   
}

This won't work, Philip:

      :0
      * COUNT ?? ^..$
      COUNT=0$COUNT
        ^^^^^^^^^^^^^  <<-- enclose it in braces
-- 
Sincerely,                                                          
srb(_at_)cuci(_dot_)nl
           Stephen R. van den Berg (AKA BuGless).

"My name is Smith, the P is not pronounced."

<Prev in Thread] Current Thread [Next in Thread>