--------------------------------< cut here >--------------------------------
Program VACATION
C
C Automatically reply to mail when you are on vacation. Uses the file
C VACATION.TXT. Create a file with this name and fill it with the
C appropriate text. Use the command file VACATION.COM to run this program
C and resubmit it as a batch job on a daily basis. The log file ANSWER.LOG
C will be created and will include the time of message, sender, and subject.
C
C The VACATION.TXT file could look like this:
C
C----------------------------------------------------------------------------
C Hello. I am on vacation at the moment and so I am unable to get back to
C you. I've left my automatic mail reply system running to let you know
C that I have received your message and will respond as soon as I return.
C
C John
C----------------------------------------------------------------------------
C
C The VACATION.COM file should look something like this:
C
C----------------------------------------------------------------------------
C $ SUBMIT/AFTER="TOMORROW" VACATION
C $ RUN VACATION
C $ EXIT
C----------------------------------------------------------------------------
C
C Author:
C
C John Howells, Sterling Software
C
C Adapted from the TMAIL program example posted to INFO-VAX
C
include '($maildef)'
character*80 buff, sender, subject
character*25 ascdate
integer mail_ctx, msg_ctx, user_ctx, msg_id, sts
integer msg_select, date_len, status
integer sender_len, subject_len
integer*2 msg_number, msg_flag
volatile msg_select, msg_number, msg_flag, msg_id
volatile date_len, sender_len, subject_len, len_buff
parameter logfile = 1
structure /itemlist/
integer*2 len
integer*2 item_code
integer*4 address
integer*4 retlen
end structure
record /itemlist/ nselect(2), text(2), msgfile(2)
record /itemlist/ newmsg(2), snewmsg(2)
record /itemlist/ msg_info(6), select(3), next(2),
. context(3)
record /itemlist/ null
C
C Blank out the following character strings so that they will format
C properly later
C
subject = ' '
sender = ' '
ascdate = ' '
C
C Set up itemlists for input items
C
C MAIL$_USER_NEW_MESSAGES returns the new message count
C MAIL$_USER_SET_NEW_MESSAGES sets the new message count
C MAIL$_MESSAGE_NEXT returns 1st record of message following current one
C
call setup ( newmsg, mail$_user_new_messages,
. %descr(msg_number), )
call setup ( snewmsg, mail$_user_set_new_messages,
. %descr(msg_number), )
call setup ( next, mail$_message_next, ' ', )
C
C Set up itemlists for characteristics of the mail message
C
C MAIL$_MESSAGE_FOLDER specifies name of target folder
C MAIL$_NOSIGNAL disables error signalling
C
call setup ( select(1), mail$_message_folder, 'NEWMAIL', )
call setup ( select(2), mail$_nosignal, ' ', )
C
C Set up itemlists for message context
C
C MAIL$_MESSAGE_CONTINUE returns the next text record of current message
C MAIL$_MESSAGE_AUTO_NEWMAIL automatically moves new messages to MAIL folder
C
call setup ( context(1), mail$_message_continue, ' ', )
call setup ( context(2), mail$_message_auto_newmail, ' ', )
C
C Set up itemlists for output items (only needed to clear out the message
C context)
C
C MAIL$_MESSAGE_SELECTED returns the number of selected messages
C MAIL$_MESSAGE_RECORD returns a record from the current message
C
call setup ( nselect,
. mail$_message_selected, %descr(msg_select), )
call setup ( text, mail$_message_record, buff,
. len_buff )
C
C Set up itemlists for information items
C
C MAIL$_MESSAGE_CURRENT_ID returns id number of the current message
C MAIL$_MESSAGE_DATE returns the message creation date string
C MAIL$_MESSAGE_SENDER returns address of the sender of the message
C MAIL$_MESSAGE_SUBJECT returns the subject text field
C MAIL$_MESSAGE_RETURN_FLAGS returns flag value of the current message
C
call setup ( msg_info(1), mail$_message_current_id,
. %descr(msg_id), )
call setup ( msg_info(2), mail$_message_date,
. ascdate, date_len )
call setup ( msg_info(3), mail$_message_sender,
. %descr(sender), sender_len )
call setup ( msg_info(4), mail$_message_subject,
. %descr(subject), subject_len )
call setup ( msg_info(5), mail$_message_return_flags,
. %descr(msg_flag), )
C
C Get number of new messages
C
C MAIL$USER_BEGIN initiates user processing
C MAIL$USER_GET_INFO gets information from user profile
C
call mail$user_begin ( user_ctx, null, null )
call mail$user_get_info ( user_ctx, null, newmsg )
C
C Open the mailfile
C
C MAIL$MAILFILE_BEGIN initiates mail file processing
C MAIL$MAILFILE_OPEN opens the mail file
C
call mail$mailfile_begin ( mail_ctx, null, null )
call mail$mailfile_open ( mail_ctx, null, null )
C
C Select the context to read messages
C
C MAIL$_MESSAGE_FILE_CTX specifies mail file context from MAIL$MAILFILE_BEGIN
C MAIL$MESSAGE_BEGIN initiates message processing
C
call setup ( msgfile, mail$_message_file_ctx,
. %descr(mail_ctx), )
call mail$message_begin ( msg_ctx, msgfile, null )
C
C select the messages that we want to read, and find out how many we got
C
C MAIL$MESSAGE_SELECT selects a message from open mail file
C
sts = mail$message_select ( msg_ctx, select, nselect )
if(.not.sts) goto 100 ! NEWMAIL folder doesn't exist
C
C Open the logfile. If it does not exist, create a new one.
C
open (unit=logfile, file='ANSWER.LOG', status='old',
. form='formatted', carriagecontrol='list', access='append',
. iostat=status)
C
C Logfile doesn't exist, create a new one
C
if (status .ne. 0) then
open (unit=logfile, file='ANSWER.LOG', status='new',
. form='formatted', carriagecontrol='list', iostat=status)
if (status .ne. 0) then
write (6,*) 'unable to open log file'
call exit
endif
write (logfile, '(t1,a,t20,a,t50,a)')
. 'Date:','From:','Subject:'
write (logfile,'(a)') '------------------------------'//
. '--------------------------------------------------'
endif
C
C Loop through and reply to all messages in NEWMAIL folder
C
C MAIL$MESSAGE_GET retrieves a message
C
do messcnt = 1,msg_select
call mail$message_get ( msg_ctx, next, msg_info(1) )
C
C Write info to the logfile
C
write (logfile, '(t1,a,t20,a,t50,a)') ascdate(1:12),
. sender(1:25), subject(1:30)
C
C Actually send the file VACATION.TXT to the sender (using the send_mail
C subroutine)
C
call send_mail ( 'Re: '//subject(1:subject_len),
. sender(1:sender_len) )
C
C We have to keep track of the number of new messages ourself.
C
if (iand(msg_flag,mail$m_newmsg).ne.0)
. msg_number = msg_number - 1
call mail$message_get ( msg_ctx, context, text )
C
C Clear out the character strings so that the logfile will be nicely
C formatted
C
subject = ' '
sender = ' '
ascdate = ' '
end do
C
C All done, do clean up
C
C MAIL$MESSAGE_END terminates message processing
C MAIL$USER_SET_INFO modifies the user profile entry
C MAIL$USER_END terminates user processing
C MAIL$MAILFILE_CLOSE closes the mail file
C MAIL$MAILFILE_END terminates mail file processing
C
100 call mail$message_end ( msg_ctx, null, null )
call mail$user_set_info ( user_ctx, snewmsg, null )
call mail$user_end ( user_ctx, null, null )
call mail$mailfile_close ( mail_ctx, null, null )
call mail$mailfile_end ( mail_ctx, null, null )
C
C Close the logfile
C
close (logfile)
end
C************************************************************************
Subroutine SEND_MAIL ( subject, sender )
C
C Send a reply to the sender explaining that I'm not here
C
include '($maildef)'
character*(*) subject, sender
structure /itemlist/
integer*2 len
integer*2 item_code
integer*4 address
integer*4 retlen
end structure
record /itemlist/ msg_info(2), null, body(2), address(2)
C
C Start by setting up the itemlists.
C
C MAIL$_SEND_USERNAME specifies the user to send to
C MAIL$_SEND_SUBJECT specifies the subject line
C MAIL$_SEND_FILENAME specifies the input file to be opened
C
call setup ( address, mail$_send_username, sender, )
call setup ( msg_info, mail$_send_subject, subject, )
call setup ( body, mail$_send_filename, 'VACATION.TXT', )
C
C Send the file to the originator of the message
C
C MAIL$SEND_BEGIN initiates send processing
C MAIL$SEND_ADD_ATTRIBUTE constructs the message header
C MAIL$SEND_ADD_BODYPART constructs the body of the message
C MAIL$SEND_ADD_ADDRESS adds the address of the originator
C MAIL$SEND_MESSAGE sends the actual message
C MAIL$SEND_END terminates send processing
C
call mail$send_begin ( send_ctx, null, null )
call mail$send_add_attribute ( send_ctx, msg_info, null )
call mail$send_add_bodypart ( send_ctx, body, null )
call mail$send_add_address ( send_ctx, address, null )
call mail$send_message ( send_ctx, null, null )
call mail$send_end ( send_ctx, null, null )
return
end
C************************************************************************
Subroutine SETUP ( item, code, string, ret_len )
C
C This subroutine is called in order to set up the itemlists needed by
C the main program
C
character*(*) string
integer ret_len
integer code
structure /itemlist/
integer*2 len
integer*2 item_code
integer*4 address
integer*4 retlen
end structure
record /itemlist/ item
item.len = len(string)
item.item_code = code
item.address = %loc(string)
item.retlen = %loc(ret_len)
return
end
-----------------------------< cut here >-----------------------------------
--------------------------------------------------------------------------------
John Howells | "Science does not | how...@pioneer.arc.nasa.gov
Sterling Software | remove the terror | how...@krypton.arc.nasa.gov
Palo Alto, Ca. | of the Gods" | howells%k...@ames-io.arpa
I sure hope everyone who uses this program makes SURE that that aren't
subscribped to ANY mailing lists. Imagine what might happen. Mailing list
XY...@SOMEWHERE.NET send mail to user X. User X, who is running this program,
replies to the mailing list that he is on vacation. The mailing list promptly
sends this message out to everyone on the list, including user X, who replies
to THAT that he is on vacation... Talk about mail loops!!!
Yes I know that many mailing lists set it up so that replies to the mail go to
the sender, but I think it is still sort of impolite. Suppose I post a
request for help about something on, say, info...@kl.sri.com. This automatic
responder will send me mail saying user X is on vacation, but will get back to
me REAL SOON NOW (TM). Now user X may or may not be able to help me, but
telling me that he is on vacation is NOT what I wanted to hear.
As an example of how to use the VMS 5 callable mail interface, this program is
quite useful. As an actual program it MUST BE USED WITH EXTREME CAUTION.
+-------------------+-------------------------------------+------------------+
| Bob Sloane \Internet: SLO...@KUHUB.CC.UKANS.EDU/Anything I said is |
| Computer Center \ BITNET: SLO...@UKANVAX.BITNET / my opinion, not my |
| University of Kansas\ AT&T: (913) 864-0444 / employer's. |
+-----------------------+-----------------------------+----------------------+
Good point! I hadn't considered this possibility when I posted it, because I
don't subscribe to any mailing lists. Indeed, PLEASE be careful when using this
because I don't wish to receive massive flames for hosing a network. Probably
the best thing for me to do is modify the program to allow for an exclusion
list of some sort. If anyone else wants to do this, feel free. I'm going on
vacation anyway! :-)
As a kluge, couldn,t you have your program
look for "-L" in the header info?
and or
Have the program check a list of callers that should
not be answered.
MAYBE BINET should have something in the
header that distinguishes broadcasts from mail? ...
BTW how do you find those article indentifiers
like
> In article <34...@kuhub.cc.ukans.edu>, SLO...@kuhub.cc.ukans.edu (Bob Sloane)
I receive the part after the @ but don't know how you
find the numeric part before the @, or what it refers to.
(My VAX is secure, so it can't have phone connections. I have
to use my I*M account to get on BITNET, so maybe it is
just a difference in handling mail.)
_________________________________________________________
Arthur J. Kendall
National Security & International Affairs Division
United States General Accounting Office (GAO)
Washington, DC 20548 USA
Commercial phone: (202) 275-8455
FTS: 275-8455
BITNET: AJK@NIHCU
GAO is an oversight agency in the legislative branch.
It is not the same as GSA which is an executive branch agency.
*** DISCLAIMER ****
This is not an official communication. Only official
communications represent official findings, results, or opinions.
Any opinions expressed are solely those of the sender as
an individual.