From:	CSBVAX::CSBVAX::MRGATE::"SMTP::CRVAX.SRI.COM::RELAY-INFO-VAX" 10-FEB-1989 14:25
To:	MRGATE::"ARISIA::EVERHART"
Subj:	Solution to mail archiving problem


Received: From KL.SRI.COM by CRVAX.SRI.COM with TCP; Thu,  9 FEB 89 19:53:21 PDT
Received: from icdc.llnl.gov by KL.SRI.COM with TCP; Thu, 9 Feb 89 19:36:32 PST
Date: Tue, 7 Feb 89 09:19 PST
From: "Steve Schaeffer, SSE Computer Operations Mgr." <SCHAEFFER@AMSTEL>
Subject: Solution to mail archiving problem
To: INFO-VAX@KL.SRI.COM
X-VMS-To: INFO-VAX

Thank you to all the folks that responded to my request for help with 
the problem of archiving mail with special thanks to Art McClinton for 
his example program. The final solution is presented below. I intend 
to run this job from a scheduler about once a month initially and 
probably more often as the volume of mail increases.

Steven J. Schaeffer
Lawrence Livermore National Laboratory
P.O. Box 808 L-546
Livermore, CA 94550

Ma Bell:	(415) 422-2304
FTS:		532-2304
INTERNET:	SCHAEFFER%LLLASD@ICDC.LLNL.GOV
-----------------------------------------------------------------------
$! Command procedure to extract all of the Incidents account mail
$! that is at least 2 months old to an archive file. The archive files
$! need to be saved for a 5-year record by a backup operation.
$!
$! Written by Steven J. Schaeffer 2/3/89
$!
$! Calculate a date that is roughly 2 months ago.
$!
$ months                = "JANFEBMARAPRMAYJUNJULAUGSEPOCTNOVDEC"
$ months_minus_two      = "NOVDECJANFEBMARAPRMAYJUNJULAUGSEPOCT"
$ time  = f$time()
$!
$ day   = f$extract(0, 2, time)
$ month = f$extract(3, 3, time)
$ year  = f$extract(7, 4, time)
$!
$! Make sure the date exists.
$ if day .gts. "28" then day = "28"
$! Back up 2 months.
$ month = f$extract(f$locate(month, months), 3, months_minus_two)
$! Subtract a year if needed.
$ if month .eqs. "NOV" .or. month .eqs. "DEC" then -
        year = f$string(f$integer(year) - 1)
$!
$ target_date = day + "-" + month + "-" + year
$!
$! Create a temporary command procedure to execute the mail operations of
$! extracting the desired messages, deleting them from Mail, and
$! cleaning out the Mail.mai file.
$!
$ set default security_user:[incidents]
$!
$ pid = f$getjpi("", "PID")
$!
$ open/write temp mail_archive_'pid'.com
$!
$ write temp  "$ mail/noedit"
$ write temp  " set file security_user:[incidents]mail.mai"
$ write temp  " select/before=''target_date' newmail"
$ write temp  " move/all/noconfirm mail"
$ write temp  " select/before=''target_date' mail"
$ write temp  " extract/all incidents_archive_''target_date'"
$ write temp  " delete/all"
$ write temp  " purge/reclaim"
$ write temp  " compress"
$ write temp  " exit"
$ write temp  "$ delete/nolog mail.old;*"
$ write temp  "$ delete/nolog mail_archive_''pid'.com;*"
$!
$ close temp
$!
$! Now execute the temporary command procedure.
$!
$ @mail_archive_'pid'
$!
$ exit

