From: CSBVAX::MRGATE!MREGO1@CLARKU.BITNET@SMTP 14-DEC-1987 18:50 To: ARISIA::EVERHART Subj: Automatically file NEWMAIL from yourself Received: from WISCVM.WISC.EDU by KL.SRI.COM with TCP; Mon 14 Dec 87 12:33:22-PST Received: from CLARKU.BITNET by WISCVM.WISC.EDU ; Mon, 14 Dec 87 14:41:47 CDT Date: Mon, 14 Dec 87 14:58 EDT From: Subject: Automatically file NEWMAIL from yourself To: info-vax@kl.sri.com X-Original-To: INFOVAX, MREGO1 This is my first message to info-vax so please pardon any stupidity. I've seen a lot of messages regarding MAIL lately, so here's my 2The following DCL program was a result of necessity, and in my opinion is a feature that should have been built into the MAIL utility. It will file all NEWMAIL messages that are from yourself into a folder called SENT. It is particularly handy if you send a lot of mail and have the SET COPY_SELF SEND,REPLY switch enabled. Any comments are welcome. p.s. This should help the person who recently inquired about finding out where their mail file is, without having it hard-coded. $ !+ $ ! NEWMAIL.COM - Written by Mike Rego 9-Dec-1987 $ ! $ ! This program will move NEWMAIL messages that are $ ! from yourself to a folder named SENT. It will $ ! not touch NEWMAIL you receive from other users. $ ! It was specifically designed to handle messages $ ! created by SEND/SELF or REPLY/SELF. $ !- $ on error then goto CLOSE $ on control_y then goto CLOSE $ !+ $ ! How many new messages are there? $ !- $ open/read/write/share/error=NOVMSMAIL vmsmail sys$system:vmsmail.dat $ uname = f$edit(f$getjpi("","username"),"collapse") $ read/key="''uname'" vmsmail vmsrec $ number = f$cvui(33*8,16,vmsrec) $ new = number ! Total new messages $ !+ $ ! Where is my mail file? $ !- $ mail_file = f$trnlnm("sys$login")+"mail.mai" ! Default $ mail_dir_len = f$cvui(65*8,8,vmsrec) $ if mail_dir_len .eq. 0 then goto INIT $ personal_name_len = f$cvui(66*8,8,vmsrec) $ forw_addr_len = f$cvui(67*8,8,vmsrec) $ mail_dir = f$ext(68+personal_name_len+forw_addr_len,mail_dir_len,vmsrec) $ seg1 = f$ext(0,f$len(f$trnlnm("sys$login"))-1,f$trnlnm("sys$login")) $ seg2 = f$ext(1,f$len(mail_dir),mail_dir) $ seg3 = "mail.mai" $ mail_file = seg1+seg2+seg3 $ INIT: $ moved = 0 ! Number of messages successfully moved $ cnt = 0 ! New messages that have been read $ first = 1 ! First record flag $ open/read/write/error=NOMAILMAI mailmai 'mail_file $ !+ $ ! Read through the new messages, and move the ones from me $ !- $ LOOP: $ if cnt .ge. new then goto END $ if first .eq. 0 then read/end=END mailmai mairec $ if first .eq. 1 then gosub READ_FIRST $ cnt = cnt + 1 $ on warning then goto loop $ from_length = f$cvui(66*8,1*8,mairec) $ from = f$extract(68,from_length,mairec) $ from_length = f$loc(" ",from) $ from = f$extract(68,from_length,mairec) $ ! It's not from me so ignore it $ if f$loc(uname,from) .ge. f$len(from) then goto LOOP $ ! It's from me so modify the record $ mairec[64,8] = 4 ! New folder name length $ mairec[72,8] = %d83 ! S $ mairec[80,8] = %d69 ! E $ mairec[88,8] = %d78 ! N $ mairec[96,8] = %d84 ! T $ mairec[104,8] = %d0 ! NUL $ mairec[112,8] = %d0 ! NUL $ mairec[120,8] = %d0 ! NUL $ ! Update the record - It's now in the new folder $ write/update mailmai mairec $ ! Decrement the number of new messages I have $ number = number - 1 $ ! Increment the number of messages moved $ moved = moved + 1 $ goto LOOP $ END: $ ! Update my new message count $ vmsrec[33*8,16] = number $ write/update vmsmail vmsrec $ write sys$output " ''moved' of ''new' new messages were moved." $ CLOSE: $ close/nolog vmsmail $ close/nolog mailmai $ exit $ READ_FIRST: $ read/index=1/key="NEWMAIL"/error=END/end=END mailmai mairec $ first = 0 $ return $ NOVMSMAIL: $ savestat = $status $ write sys$output "ERROR OPENING SYS$SYSTEM:VMSMAIL.DAT" $ write sys$output "''f$message(savestat)'" $ exit $ NOMAILMAI: $ savestat = $status $ write sys$output "ERROR OPENING MAIL.MAI" $ write sys$output "''f$message(savestat)'" $ goto CLOSE Mike Rego - MREGO1@CLARKU.BITNET