Hi,
Here is a com file that will create a com file to delete all the mail
messages that contain a given string in the directory listing. I have changed
delete to extract for your purposes. Then of course you must run the new com
file on mail.
Basically, you must supply a file (dir.lis) which gives the directory
listing of mail. Then the com file scans the listing and looks for a string.
If it finds a match, it will generate 'code' to extract the file. The
new comfile is called extract.out.
Here is an example of a file that creates dir.lis:
$! file mkdir.com
$ mail
$ deck
dir
exit
$ eod
$ exit
Invoke this via: spawn/output=dir.lis @mkdir
Then invoke the other one in the same way but do not make the output of the
spawn 'extract.com' since the comfile does it for you. Rather make it
something like /output=create.log.
Perhaps, there is an easier way but I don't know because I never use VMS mail.
I use mail on a sun system via emacs. I only wish someone would write an
emacs rmail interface to vms.
--John
PS. see first comment below for handling lowercase searches.
----------------(cut here)--------------------------------
$! Next line reads in search string. Use "" for lowercase, eg,
$! address ---> "ADDRESS" but "address" ---> "address"
$!
$ inquire string "Enter Search String: "
$ sho sym string
$ open in_file dir.lis
$ open/write out_file extract.com
$ write out_file "$mail"
$ write out_file "$deck"
$ LOOP:
$ do_it=0
$ number = ""
$ flag = 0
$ read/end_of_file=FINISH in_file line
$ if (f$locate(string,line) .lt. f$length(line))
$ then
$ REPEAT:
$ char = f$extract(0,1,line)
$ if (char .eqs. " ")
$ then
$ if (flag .eq. 1) then do_it=1
$ line=line - " "
$ goto REPEAT
$ else
$ flag = 1
$ line = line - char
$ if (do_it .ne. 1)
$ then
$ number = number + char
$ goto REPEAT
$ endif
$ write out_file "''number'"
$ write out_file "extract/append mail.out"
$ endif
$ endif
$ goto LOOP
$!
$ FINISH:
$ write out_file "$eod"
$ write out_file "$exit"
$ close in_file
$ close out_file
$ exit
--
--John
bitnet: davis@ohstpy
internet: da...@pacific.mps.ohio-state.edu