home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 35 Internet / 35-Internet.zip / s_pmmail.zip / pmmailer.CMD
OS/2 REXX Batch file  |  1997-06-09  |  6KB  |  172 lines

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