Article 168579 of comp.os.vms:
Claudia Martinez wrote:
>> Does anyone know how to get the new mail count into a DCL symbol.. or how
>> I might get it into an integer in C?  Is there an existing function to do
>> this? We are running OpenVMS v6.2-1H2.   Thanks!

Here's the program I wrote long ago, which stores user's new mail count into
a DCL symbol (named GETCNT_NEWMSG in the program). Username can be provided
either in a separate DCL symbol (GETCNT_USERNAME) or via standard input.
Hope it will be helpful

!------------------------------- GETCNT.FOR -------------------------------

	program get mail count
	   include '($maildef)'

           structure /itmlist/ ! "VMS usage: item_list_3"
              union
                 map
                    integer*2 bufferlen
                    integer*2 itemcode
                    integer*4 bufferaddr
                    integer*4 lengthaddr
                 end map
                 map
                    integer*4 endlist
                 end map
              end union
           end structure
 
           record /itmlist/ in(2), out(2), null(2)
	   character*12 user, username
	   integer context, cnt*2

! -----    Get Username from GETCNT_USERNAME symbol or from SYS$INPUT

	   call lib$get_symbol ('GETCNT_USERNAME', username, iuser)
           if (iuser.eq.0) then
      	      write (*,'(1X,A,$)') 'Username: '
	      read (*,'(A)') username
	   endif

	   context=0

! -----    Set what we want to get ...

	   in(1).bufferlen = 12
	   in(1).itemcode  = mail$_user_username
	   in(1).bufferaddr = %loc(username)
	   in(1).lengthaddr = %loc(iuser)
	   
	   in(2).endlist=0

           out(1).bufferlen = 2	  
	   out(1).itemcode  = mail$_user_new_messages
	   out(1).bufferaddr = %loc(cnt)
	   out(1).lengthaddr = %loc(ipers)

	   out(2).endlist = 0

	   null(1).bufferlen = 0
	   null(1).itemcode = 0
	   null(1).bufferaddr = 0
	   null(2).lengthaddr = 0

	   null(2).endlist = 0

! -----    Calling MAIL$ functions to obtain info

           call mail$user_begin(context, null, null)
           call mail$user_get_info(context, in, out)
           call mail$user_end(context, null, null)

! -----    Set up DCL symbol GETCNT_NEWMSG to point to the message number

	   write (user,*) cnt
	   call lib$set_symbol ('GETCNT_NEWMSG', user)
	end

!---------------------------- End of GETCNT.FOR ----------------------------
-- 

.-------.
| --+-- |  Berislav Todorovic, B.Sc.E.E.     | E-mail: beri@ubbg.etf.bg.ac.yu
|  /|\     UBBG System administrator         |          
|-(-+-)-|  School of Electrical Engineering  | Phone:  (+381-11) 3221-419
|  \|/     Bulevar Revolucije 73             |                   3224-430
| --+-- |  11000 Belgrade SERBIA, YUGOSLAVIA | Fax:    (+381-11) 3248-681
`-------' --------------------------------------------------------------------


