home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 35 Internet / 35-Internet.zip / mailer.zip / Mailer.cmd next >
OS/2 REXX Batch file  |  1997-05-13  |  6KB  |  166 lines

  1. /*----------------------------------------------------------------------------
  2.   File:    Mailer.cmd                               Administrator: DFX Systems
  3.                                                     Creation date:    05/09/97
  4.  
  5.   Project: <None>                                   Last update:      05/13/97
  6.     ------------------------------------------------------------------------
  7.     Purpose:
  8.       This file allows PmMail to be used when replying or forwarding through
  9.       mail in Slrn.
  10.  
  11.     ------------------------------------------------------------------------
  12.     Notes:
  13.       PmMail provides a utility, PmMSend.exe, that can be used to send
  14.       e-mail messages from the command line.  It takes as parameters:
  15.  
  16.         The address of the recipient of the e-mail.
  17.         The subject of the message.
  18.         The name of a text file containing only the text of the message.
  19.  
  20.       The logic of this command file is simple.  It parses the first two
  21.       header lines of the e-mail file produced by Slrn to get the recipient
  22.       address, and the subject.  Then it skips down to the body of the
  23.       message and writes every line of the message to a temporary file.
  24.       Once it has these items, it uses them to call PmMSend.exe to send the
  25.       e-mail.
  26.  
  27.     Usage:
  28.       In the Slrn.rc file, set the sendmail_command to read as follows,
  29.       (substituting the proper path for your system.) :
  30.  
  31.         set sendmail_command "I:/Comm/Slrn/Home/Mailer.cmd"
  32.  
  33.       In the first few lines of this program is a set up section.  Change
  34.       the values of the variables in that section to match your system.
  35.  
  36.       That should be all you need to do.  If you have any problems or
  37.       comments you can e-mail me at the address below:
  38.  
  39.         Mark Miesfeld
  40.         DFX Systems
  41.         5110 E Bellevue St #109
  42.         Tucson AZ 85712
  43.  
  44.         miesfeld@acm.org
  45.  
  46.   ----------------------------------------------------------------------------*/
  47.  
  48.   /* - - - - - - - - - - Set up section:  - - - - - - - - - - - - - - - - - - */
  49.   /* Drive and directory where PmMail.exe and PmMSend.exe reside.             */
  50.   PmMailDrive = 'I:'
  51.   PmMailDir   = '\Comm\SouthSide\PmMail'
  52.  
  53.   /* The name of the PmMail account from which the message is to be sent.     */
  54.   MailAccount = 'MIESFEL1.ACT'
  55.   /* - - - - - - - - End of set up section: - - - - - - - - - - - - - - - - - */
  56.  
  57.   arg FileName
  58.  
  59.   /* Do not write messages to the screen. */
  60.   '@echo off'
  61.   StdOut = '> nul'
  62.  
  63.   /*
  64.    *  For some reason when Slrn passes the name of the e-mail message file,
  65.    *  it has a leading space.  If this is not stripped off, linein() fails.
  66.    */
  67.   MailFile = strip( FileName )
  68.   TempFile = GetTempFileName()
  69.  
  70.   /*
  71.    *  Read and parse the first 2 lines to get the e-mail recipient and the
  72.    *  message subject.
  73.    */
  74.   SendToLine  = linein( MailFile )
  75.   SendTo      = strip( substr( SendToLine, 4 ) )
  76.   SubjectLine = linein( MailFile )
  77.   Subject     = strip( substr( SubjectLine, 9 ) )
  78.  
  79.   /*
  80.    *  PmMSend expects only the message text in the file it is sent, it then
  81.    *  adds its own headers.
  82.    *
  83.    *  Here we want to skip through the rest of the header lines and then copy
  84.    *  only the message text to the temporary file.  A blank line separates the
  85.    *  headers from the message text.
  86.    */
  87.   Line = linein( MailFile )
  88.   do while lines( MailFile ) & Line <> ""
  89.     Line = linein( MailFile )
  90.   end
  91.  
  92.   do while lines( MailFile )
  93.     rc = lineout( TempFile, linein( MailFile ) )
  94.   end
  95.  
  96.   /* Close the files. */
  97.   rc = lineout( MailFile )
  98.   rc = lineout( TempFile )
  99.  
  100.   /*
  101.    *  Save the local environment, change to the PmMail directory, use PmMSend
  102.    *  to mail the message, then restore the environment.
  103.    */
  104.   rc = setlocal()
  105.     PmMailDrive
  106.     'cd' PmMailDir
  107.     'pmmsend /m' TempFile '"'SendTo'"' '"'Subject'"' MailAccount StdOut
  108.   rc = endlocal()
  109.  
  110.   /* Delete our temporary file and we are done. */
  111.   'del' TempFile
  112.  
  113.   exit
  114.  
  115. /* End of program entry routine. */
  116.  
  117.  
  118. /* - - - - - - - - - - - - - - Subroutines: - - - - - - - - - - - - - - - - - */
  119.  
  120. /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*
  121.  |  GetTempFileName()                                                         |
  122.  |    Generates an unique, fully qualifed file name.  This is intended to be  |
  123.  |    used as a temporary file.  If a TEMP directory is specified in the      |
  124.  |    environment this is used for the directory.  If not, the current        |
  125.  |    directory is used.                                                      |
  126.  |                                                                            |
  127.  |  Parameters on entry:                                                      |
  128.  |    No parameters.                                                          |
  129.  |                                                                            |
  130.  |  Returns:                                                                  |
  131.  |    An unique fully qualified file name.                                    |
  132.  |                                                                            |
  133.  * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
  134. GetTempFileName:  procedure
  135.  
  136.   /* Look for one of these common environment values. */
  137.   TEMPVAR.1 = 'TEMP'
  138.   TEMPVAR.2 = 'TMP'
  139.   TEMPVAR.3 = 'TMPDIR'
  140.   TEMPVAR.4 = 'TEMPDIR'
  141.  
  142.   rc = rxfuncadd( 'SysTempFileName', 'RexxUtil', 'SysTempFileName' )
  143.  
  144.   TempDir = ''
  145.   do i = 1 to 4 while TempDir == ''
  146.     TempDir = value( TEMPVAR.i,, 'OS2ENVIRONMENT' )
  147.   end
  148.  
  149.   if TempDir = '' then
  150.     TempDir = directory()
  151.  
  152.   FileName = SysTempFileName( 'Mail??.???' )
  153.  
  154.   if right( TempDir, 1, ) = '\' then
  155.     TempFile = TempDir ||  FileName
  156.   else
  157.     TempFile = TempDir || '\' || FileName
  158.  
  159.   rc = rxfuncdrop( 'SysTempFileName' )
  160.  
  161.   return TempFile
  162.  
  163. /* End GetTempFileName() */
  164.  
  165. /* - - - End Of File: Mailer.cmd  - - - - - - - - - - - - - - - - - - - - - - */
  166.