home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 35 Internet / 35-Internet.zip / frmck112.zip / inetmail.cmd < prev    next >
OS/2 REXX Batch file  |  1998-02-11  |  3KB  |  88 lines

  1. /* Rexx Script */
  2.  
  3. /*
  4.  * This script is based on the "automatic reply rexx script" 
  5.  * It sends a passed text with a passed subject via inet.mail to an also
  6.  * passed username.
  7.  *
  8.  * Please modify the settings...
  9.  *
  10.  * Usage: inetmail.cmd <UserName> <MsgFile> <Subject>
  11.  *        
  12.  */
  13.  
  14. /* Created: August 20, 1997 */
  15. /* Added: September 15, 1997 */
  16.  
  17.  
  18. Env = 'OS2ENVIRONMENT'
  19. ReplyTo = 'info'                   /* Point to an address for more info */
  20. Mailer = 'hmailer'
  21. WhereAmI = 'ddan.dyn.ml.org'       /* Define to your local hostname */
  22. Sender = 'postmaster'           /* Where errors will go */
  23.  
  24. /* The external functions we need */
  25. call RxFuncAdd 'SysTempFileName', 'RexxUtil', 'SysTempFileName'
  26. call RxFuncAdd 'SysFileDelete', 'RexxUtil', 'SysFileDelete'
  27.  
  28. /* start main function */
  29. /* The first arg is who the message is sent to.
  30.  * The second is the filename to be sent.  The third it the 
  31.  * Subject
  32.  */
  33. parse arg UserName MsgFile Subject
  34.  
  35. /* Find out where the files are */
  36. AutoReply = value('autoreply',,Env)  /* comment this line to not use the environment variable */
  37. /* AutoReply = 'f:\inetmail\forms' */  /* uncomment this line to specify a directory */
  38.  
  39. /* change to the directory for autoreply files */
  40. Junk = directory(AutoReply)
  41.  
  42. /* create a temp file for the outgoing message */
  43. OutFile = SysTempFileName('f?????.tmp', '?');
  44. rc = stream(OutFile, 'C', 'OPEN WRITE')  /* open the file for writing */
  45. call WriteHeaders /* the headers for the outgoing message */
  46. rc = stream(OutFile, 'C', 'close')       /* close the file */
  47.  
  48. /* creat a temp file for the outgoing destionations */
  49. Emailfile = SysTempFileName('e?????.tmp', '?')
  50. rc = Stream(Emailfile, 'C' , 'OPEN WRITE')
  51. rc = lineout(Emailfile, Username, )
  52. rc = stream(Emailfile, 'C', 'close')
  53.  
  54. ReplyFile = AutoReply'\'MsgFile   /* append the reply file to the */
  55. rc = AppendLock(ReplyFile OutFile)      /* headers file */
  56.  
  57. say 'Calling mailer'
  58. /* now start the mailer */
  59. Mailer Sender'@'WhereAmI EmailFile OutFile
  60.  
  61. return
  62.  
  63. /* ------------------------------------------------------------------ */
  64. /*
  65.  * Write out our standard headers for a message
  66.  *
  67.  */
  68.  
  69. WriteHeaders:  /* note that we have full access to all globals here */
  70.  
  71. TimeZone = value( 'TZ', , Env)
  72. TmpTime = time('N')
  73. DayOfWeek = date('W')
  74. DayOfWeek = left(DayOfWeek, 3)
  75. TmpDate = date('N')
  76. /* we put in the local time for date so that posts are chronological */
  77. rc = lineout(OutFile, 'From:' Sender '<'Sender'@'WhereAmI'>', )
  78. if ReplyTo <> '' then
  79.   rc = lineout(OutFile, 'Reply-To:' ReplyTo, )
  80. rc = lineout(OutFile, 'Date:' DayOfWeek',' TmpDate TmpTime TimeZone, )
  81. rc = lineout(OutFile, 'To:' UserName, )
  82. rc = lineout(OutFile, 'Subject: ' Subject, )
  83. /* rc = lineout(OutFile, 'OS/2 Rexx Form reply script for Inetmail 1.0', ) */
  84. rc = lineout(OutFile, '', )
  85.  
  86. return
  87.  
  88. /* ------------------------------------------------------------------ */