HP OpenVMS Systems

ask the wizard
Content starts here

Using MAIL$ API from Fortran?

» close window

The Question is:

 
How do I display  mail folders  using the callable mail interface with
Fortran?
 
The example in the system routines manual is unclear.
 
 
Thanks!
 


The Answer is :

 
  Please contact the Compaq Customer Support Center, or check DSNlink for
  access to various programming examples.  A simple example of using the
  callable MAIL API from Fortran follows:
 
 
      program call_mail
      ! 24-JAN-1989 Mike Taylor, Digital Equipment Corporation
      ! Test using callable mail to access user profile
 
      implicit integer(a-z)
 
      include '($MAILDEF)'
C      include '($rmsdef)/list'  ! only need rms$_eof
      PARAMETER RMS$_EOF = '0001827A'X
 
      external lib$get_input, lib$put_output
 
      Integer Status ! return status
      Integer context
 
      character*31  user_name, return_user_name
      integer       user_name_length, return_user_name_length
      character*255 personal_name
      integer       personal_name_length
 
      ! define list structure
      structure /item_list/
        union
          map
             integer*2 buflen, itmcod
             integer*4 bufadr, retadr
          end map
          map
              integer*4 end_list
          end map
        end union
      end structure
 
      ! most mail$ routine have the format ( context, item_list, item_list )
 
      record /item_list/null_list    ! used where item list has no codes
      record /item_list/in_list(20)  ! input list
      record /item_list/out_list(20) ! output list
 
      null_list.end_list = 0   ! null list
      context = 0
 
      ! get a user name
      status = lib$get_input( user_name, ' User''s name ',
     +                        user_name_length )
      if (status .EQ. rms$_eof ) stop
      if (.NOT. status ) call lib$signal ( %val( status ) )
 
 
      in_list(1).buflen = user_name_length  ! can not exceed 31
      in_list(1).itmcod = mail$_user_username
      in_list(1).bufadr = %LOC( user_name )
      in_list(1).retadr = %LOC( user_name_length )
      in_list(2).end_list = 0   ! null list
 
      out_list(1).buflen  = LEN( return_user_name ) ! can not exceed 31
      out_list(1).itmcod  = mail$_user_return_username
      out_list(1).bufadr  = %LOC( return_user_name )
      out_list(1).retadr  = %LOC( return_user_name_length )
 
      out_list(2).buflen = 255
      out_list(2).itmcod = mail$_user_personal_name
      out_list(2).bufadr = %LOC( personal_name )
      out_list(2).buflen = 255
 
      out_list(2).itmcod = mail$_user_personal_name
      out_list(2).bufadr = %LOC( personal_name )
      out_list(2).retadr = %LOC( personal_name_length )
 
      out_list(3).end_list = 0   ! null list
 
      status = mail$user_begin( context, null_list, null_list )
      if ( .NOT. status ) call lib$signal ( %val( status ) )
 
      status = mail$user_get_info( context, in_list, out_list )
      if (status .EQ. rms$_eof ) stop
      if ( .NOT. status ) call lib$signal ( %val( status ) )
 
      type *, ' looking for ',  user_name(1:user_name_length )
      type *, ' returned user name ',
     +        return_user_name(1:return_user_name_length )
 
      type *, ' ',  personal_name(1:personal_name_length )
 
      status = mail$user_end( context , null_list, null_list )
      if ( .NOT. status ) call lib$signal ( %val( status ) )
 
      END
 

answer written or last revised on ( 27-NOV-1999 )

» close window