	PROGRAM MAIL MESSAGES
C***************************************************************************
C***
C***	This program ia a quick and dirty utility to see how many mail
C***	messages have been unread by users.
C***
C***	Author :	Jeff Cameron
C***			jcam90502@jcameron.com
C***			http://www.jcameron.com/vms/
C***
C***	Modification history :
C***
C***	Programmer	Date		Description
C*** ----------------------------------------------------------------------
C***	Jeff Cameron	15-DEC-1990	Initially written
C*** ----------------------------------------------------------------------
C***
C***************************************************************************
	CHARACTER*31 INPUT, USER
	INTEGER*2 MAILWORDS (3)
C
	CHARACTER*31 PROFILE_FILE /'SYS$SYSTEM:VMSMAIL_PROFILE.DATA'/
C
	INTEGER*4 TYO /6/, TYI /5/, MAI /7/
C
 1	FORMAT (A)
C
C***	OPEN THE MAILE FILE
	OPEN (	UNIT=MAI,
	1	NAME=PROFILE_FILE,
	2	TYPE='OLD',
	3	READONLY,
	4	SHARED,
	5	FORM='UNFORMATTED',
	6	ACCESS='KEYED',
	7	IOSTAT=IOSTAT)
C
	IF (IOSTAT .NE. 0) THEN
	    WRITE (TYO,1) ' %MAILMESS-F-MAILOPENFAIL, Failed to open ' //
	1		  PROFILE_FILE
	    CALL RT_ERROR (TYO,IOSTAT)
	    CALL EXIT
	ELSE
	ENDIF
C
C***	GET THE USERNAME
 10	WRITE (TYO,11)
 11	FORMAT (' Enter Username, "*" for all, or Control-Z to exit : ',$)
	READ (TYI,1,END=1000) INPUT
	CALL UPCASE (INPUT)
	LI = LENGTH (INPUT)
C
	WRITE (TYO,13)
	WRITE (TYO,14)
 13	FORMAT (1X,'Username    ',9X,'  #  ')
 14	FORMAT (1X,'------------',9X,'-----')
C
	IF ((LI .EQ. 0) .OR.
	1   (INPUT (1:LI) .EQ. '*')) THEN
 20	    READ (MAI,END=25) USER, MAILWORDS
	    NEWMESS = IAND (MAILWORDS(3),'00FF'X)
	    IF ((NEWMESS .NE. 0) .OR. (INPUT(1:LI) .NE. '*')) 
	1	WRITE (TYO,21) USER(1:12), NEWMESS
 21	    FORMAT (' ',A12,10X,I3)
	    GO TO 20
 25	    CONTINUE
	ELSE
	    READ (MAI,KEY=INPUT) USER, MAILWORDS
	    NEWMESS = IAND (MAILWORDS(3),'00FF'X)
	    WRITE (TYO,21) USER, NEWMESS
	ENDIF
	GO TO 10
C
C***	ALL DONE
 1000	CLOSE (UNIT=MAI)
	CALL EXIT
	END
