From:	SMTP%"smithdm@ldoc03.ldc.dupont.com" 12-SEP-1993 17:48:54.18
To:	EVERHART
CC:	
Subj:	RE: Checkmail Count Utility?

X-Newsgroups: comp.os.vms
From: smithdm@ldoc03.ldc.dupont.com (David M. Smith)
Subject: RE: Checkmail Count Utility?
Message-Id: <1993Sep11.152952.29101@es.dupont.com>
Sender: news@es.dupont.com (USENET News System)
Nntp-Posting-Host: ldoc03.lvs.dupont.com
Reply-To: smithdm@ldoc03.ldc.dupont.com
Organization: DuPont (Opinions are those of the writer only)
Date: Sat, 11 Sep 1993 15:29:52 GMT
Lines: 102
To: Info-VAX@kl.sri.com
X-Gateway-Source-Info: USENET

In article <15540200@MVB.SAIC.COM>, 
simons/G=Colin/S=Sewell/O=H.A.Simons.Ltd/OU=PACIFIC@mhs.attmail.com writes:
>>Does anybody know of an easy way or of an Utility that will list the
>>number of unread mail msgs users have, I want to do a wildcard sweep of
>>my users to determine how many unread msgs they have.  I came across a user
>>today who has over 2000 unread msgs.  Thanks in advance.

I wrote a command procedure to extract the VMSmail newmail count from
VMSMAIL_PROFILE for a specified user and either display it or put it into a DCL
global symbol.  You could use this as a basis for a simple tool: run AUTHORIZE
and create a listing file, then OPEN that and extract the username from each
line, and call this procedure.  This is left as an exercise for the reader.

+--- cut here ----------------------------------------------------------------+
$! GET_VMSMAIL_COUNT.COM -- Procedure to Display a User's VMSmail Profile
$   say = "write sys$output"
$   fac = "%" + f$parse (f$environment ("procedure"),,,"name") + "-"
$   exit_status = 1
$   on control_y then $ goto control_y_exit
$   on error then $ goto fatal_error
$   req_privs = "readall"
$   old_privs = f$setprv (req_privs)
$   if .not. f$privilege (req_privs) then $ goto no_priv
$!
$   username = f$edit (p1,"trim,upcase")
$   if username .eqs. "" then $ inquire username "Username"
$   if username .eqs. "" then $ goto final_exit
$!
$   key_length = 31
$   key = f$fao("!#AS",key_length,username)
$   vmsmail_profile = f$parse ("VMSMAIL_PROFILE","SYS$SYSTEM:.DATA")
$   open/read/share=write get_vmsmail_count_in 'vmsmail_profile'
$   read/key="''key'"/error=no_vmsmail_profile get_vmsmail_count_in record
$   close get_vmsmail_count_in
$   start = 31
$loop:
$   code = f$cvui(0,16,f$extract(start,2,record))
$   size = f$cvui(0,16,f$extract(start+2,2,record))
$   data = f$extract(start+4,size,record)
$   if code .eq. 1 then $ gvc_newmail = f$cvui(0,size*8,data)
$   start = start + 4 + size
$   if start .lt. f$length (record) then $ goto loop
$end_loop:
$   if f$type (gvc_newmail) .eqs. "" then $ goto no_newmail_count
$   if p2 .eqs. ""
$   then
$	say f$fao ("!ASI-COUNT, NEWMAIL count in VMSmail profile is !SL",fac, -
	    gvc_newmail)
$   else
$	'p2' == 'gvc_newmail'
$   endif
$final_exit:
$   if f$type (old_privs) .nes. "" then $ old_privs = f$setprv (old_privs)
$   exit exit_status
$!
$! Error exits:
$!
$fatal_error:
$   say fac,"F-FATAL, unexpected error detected"
$   exit_status = %x10000004
$   goto final_exit
$control_y_exit:
$   say fac,"E-ABORT, aborted by Control Y"
$   exit_status = %x10000002
$   goto final_exit
$no_priv:
$   say fac, -
        "E-NOPRIV, no privilege for attempted operation (need ''req_privs')"
$   exit_status = %x10000002
$   goto final_exit
$no_vmsmail_profile:
$   close/nolog get_vmsmail_count_in
$   say fac,"E-NOPROFILE, no VMSmail profile record found"
$   exit_status = %x10000002
$   goto final_exit
$no_newmail_count:
$   say fac,"E-NOCOUNT, no NEWMAIL count found in profile record"
$   exit_status = %x10000002
$   goto final_exit
$!++
$! GET_VMSMAIL_COUNT.COM -- Procedure to Display a User's VMSmail Profile
$!
$!	This procedure is called to display the VMSmail profile record for a
$!	specified user.
$!
$!	Call sequence:
$!
$!           @get_vmsmail_count username [return-symbol]
$!
$!	where 'username' is the name of the VMS user to be checked and
$!	'return-symbol', if specified, is the global symbol to which the value
$!	is to be returned.  If 'return-symbol' is not specified then the value 
$!	is displayed via an informational message.
$!--
$! Revision history:
$!
$!  6-Dec-1990	David M. Smith	Initial version - extracted from
$!		DISPLAY_VMSMAIL_PROFILE.COM.
$!
$! 22-Oct-1992	David M. Smith - use fully expanded username as key to avoid
$!		possibly reading wrong record from VMSMAIL_PROFILE.
$!

