From:	SMTP%"RELAY-INFO-VAX@CRVAX.SRI.COM" 12-JUN-1993 11:18:42.92
To:	EVERHART
CC:	
Subj:	Re: Extracting return addresses from MAIL.MAI

Date: Thu, 10 Jun 1993 10:08:50 +0100
From: Arne Vajhxj <ARNE@kopc.hhs.dk>
Subject: Re: Extracting return addresses from MAIL.MAI
To: SYSTEM@SPANKY.PAS.ROCHESTER.EDU, INFO-VAX@sri.com
Message-Id: <01GZ7JO925LU9GVCO0@kopc.hhs.dk>
X-Vms-To: KOPC::IN%"SYSTEM@SPANKY.PAS.ROCHESTER.EDU"
X-Vms-Cc: IN::"INFO-VAX@SRI.COM"
Mime-Version: 1.0
Content-Type: TEXT/PLAIN; CHARSET=ISO-8859-1
Content-Transfer-Encoding: 8BIT

> Hi folks - I have to build a mail distribution list from about five year's
> worth of mail messages for a professor here.  He's moving and wants to send
> an email message to everyone who's written to him in the past five years -
> go figure.

I can't, but who can really understand a user with all their weird ideas.
Well - no users - no system managers. God bless the users.

>            Does anyone know of a simple way to strip out the From: field
> in the MAIL.MAI file?  Is it a separate key?  An indexed-file editor would
> be handy, too.  Thanks for any help!  Please respond directly, as I am not
> on this mailing list.

Use callable mail !

The following piece of MACRO and the test-program in FORTRAN should do the job.

      PROGRAM TEST
      INTEGER*4 MM
      PARAMETER (MM=1000)
      INTEGER*4 N,LFROM(MM),LSUBJ(MM),TIME(2,MM),SIZE(MM),I
      CHARACTER*23 STIME
      CHARACTER*256 FROM(MM)
      CHARACTER*256 SUBJ(MM)
      CALL MAIL_LOOKUP('MAIL',N,FROM,LFROM,SUBJ,LSUBJ,TIME,SIZE)
      DO 100 I=1,N
        WRITE(*,*) 'FROM:',FROM(I)(1:LFROM(I))
        WRITE(*,*) 'SUBJ:',SUBJ(I)(1:LSUBJ(I))
        CALL SYS$ASCTIM(,STIME,TIME(1,I),)
        WRITE(*,*) 'TIME:',STIME
        WRITE(*,*) 'SIZE:',SIZE(I)
100   CONTINUE
      END

        .title  mail
        $MAILDEF
        $MAILMSGDEF
;
; writeread data section
;
        .psect  $LOCAL quad,pic,con,lcl,noshr,noexe,wrt
argl_mail:                              ; argumentlist MAIL$XXXXXXXX
        .long   3
        .blkl   1                       ; contxt
        .blkl   1                       ; input
        .blkl   1                       ; output
file:   .blkl   1
read:   .blkl   1
nul:    .long   0
itmlst: .blkw   1
        .blkw   1
        .blkl   1
        .blkl   1
        .word   0
        .word   MAIL$_NOSIGNAL
        .long   0
        .long   0
        .long   0
itml2:  .blkw   1
        .blkw   1
        .blkl   1
        .blkl   1
        .word   0
        .word   MAIL$_NOSIGNAL
        .long   0
        .long   0
        .long   0
itml3:  .blkw   1
        .blkw   1
        .blkl   1
        .blkl   1
        .blkw   1
        .blkw   1
        .blkl   1
        .blkl   1
        .long   0
buf:    .blkb   80
time:   .blkq   1
;
; code section
;
        .psect  $CODE quad,pic,con,lcl,shr,exe,nowrt
;***************************************
;
;  MAIL_LOOKUP ( FOLDER , N , FROM , LFROM , SUBJ , LSUBJ , TIME, SIZE )
;
;  lookup folder
;
;***************************************
        .entry  mail_lookup,^m<r2,r3,r4,r5,r6,r7,r8,r9,r10>
        moval   file,argl_mail+4
        moval   nul,argl_mail+8
        moval   nul,argl_mail+12
        callg   argl_mail,G^MAIL$MAILFILE_BEGIN
        moval   file,argl_mail+4
        moval   nul,argl_mail+8
        moval   nul,argl_mail+12
        callg   argl_mail,G^MAIL$MAILFILE_OPEN
        movw    #4,itmlst
        movw    #MAIL$_MESSAGE_FILE_CTX,itmlst+2
        moval   file,itmlst+4
        movl    #0,itmlst+8
        moval   read,argl_mail+4
        moval   itmlst,argl_mail+8
        moval   nul,argl_mail+12
        callg   argl_mail,G^MAIL$MESSAGE_BEGIN
        movl    B^4(ap),r0
        movw    (r0),itmlst
        movw    #MAIL$_MESSAGE_FOLDER,itmlst+2
        movl    4(r0),itmlst+4
        movl    #0,itmlst+8
        moval   read,argl_mail+4
        moval   itmlst,argl_mail+8
        moval   nul,argl_mail+12
        callg   argl_mail,G^MAIL$MESSAGE_SELECT
        movl    #0,@B^8(ap)
100$:   movw    #0,itmlst
        movw    #MAIL$_MESSAGE_NEXT,itmlst+2
        movl    #0,itmlst+4
        movl    #0,itmlst+8
        moval   read,argl_mail+4
        moval   itmlst,argl_mail+8
        moval   nul,argl_mail+12
        callg   argl_mail,G^MAIL$MESSAGE_GET
        cmpl    r0,#MAIL$_MSGINFO
        beql    200$
        brw     700$
200$:   movl    @B^8(ap),r6
        incl    @B^8(ap)
        movw    #4,itml3
        movw    #MAIL$_MESSAGE_SIZE,itml3+2
        mull3   #4,r6,r0
        addl2   B^32(ap),r0
        movl    r0,itml3+4
        movl    #0,itml3+8
        movw    #8,itml3+12
        movw    #MAIL$_MESSAGE_BINARY_DATE,itml3+14
        moval   time,itml3+16
        movl    #0,itml3+20
        moval   read,argl_mail+4
        moval   nul,argl_mail+8
        moval   itml3,argl_mail+12
        callg   argl_mail,G^MAIL$MESSAGE_INFO
        mull3   #8,r6,r0
        addl2   B^28(ap),r0
        movq    time,(r0)
        mull3   #4,r6,r0
        addl3   r0,B^16(ap),r8
        movl    B^12(ap),r1
        cvtwl   (r1),r9
        mull3   r9,r6,r0
        addl3   r0,B^4(r1),r10
        jsb     mail_read_skip
        jsb     mail_skip
        jsb     mail_skip
        mull3   #4,r6,r0
        addl3   r0,B^24(ap),r8
        movl    B^20(ap),r1
        cvtwl   (r1),r9
        mull3   r9,r6,r0
        addl3   r0,B^4(r1),r10
        jsb     mail_read_skip
        jsb     mail_skip
        brw     100$
700$:   moval   read,argl_mail+4
        moval   nul,argl_mail+8
        moval   nul,argl_mail+12
        callg   argl_mail,G^MAIL$MESSAGE_END
        moval   file,argl_mail+4
        moval   nul,argl_mail+8
        moval   nul,argl_mail+12
        callg   argl_mail,G^MAIL$MAILFILE_CLOSE
        moval   file,argl_mail+4
        moval   nul,argl_mail+8
        moval   nul,argl_mail+12
        callg   argl_mail,G^MAIL$MAILFILE_END
        ret
;***************************************
;
;  mail_read , r10 = stradr , r9 = maxlen , r8 = lenadr , r7 = stat
;
;  read item
;
;***************************************
mail_read:
        movw    #0,itmlst
        movw    #MAIL$_MESSAGE_CONTINUE,itmlst+2
        movl    #0,itmlst+4
        movl    #0,itmlst+8
        movw    r9,itml2
        movw    #MAIL$_MESSAGE_RECORD,itml2+2
        movl    r10,itml2+4
        movl    r8,itml2+8
        moval   read,argl_mail+4
        moval   itmlst,argl_mail+8
        moval   itml2,argl_mail+12
        callg   argl_mail,G^MAIL$MESSAGE_GET
        cmpl    r0,#MAIL$_MSGTEXT
        bneq    100$
        movl    #0,r7
        rsb
100$:   movl    #1,r7
        rsb
;***************************************
;
;  mail_read_skip , r10 = stradr , r9 = maxlen , r8 = lenadr , r7 = stat
;
;  read item but skip first 6 characters
;
;***************************************
mail_read_skip:
        pushl   r9
        pushl   r10
        movl    #80,r9
        moval   buf,r10
        jsb     mail_read
        popl    r10
        popl    r9
        subl2   #6,(r8)
        movc3   (r8),buf+6,(r10)
        rsb
;***************************************
;
;  mail_skip , r11=retadr 
;
;  skip item
;
;***************************************
mail_skip:
        moval   buf+76,r8
        movl    #76,r9
        moval   buf,r10
        jsb     mail_read
        rsb
        .end

Hope it helps !

PS: And before anyone starts screaming about my MACRO programming style, then
    I will say, that the above was cut out of a larger program and modified
    in 10 minutes !

                                                          Arne

Arne Vajhxj                             local DECNET:  KO::ARNE
Computer Department                     PSI:           PSI%238310013040::ARNE
Business School of Southern Denmark     Internet:      ARNE@KO.HHS.DK


