home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 35 Internet / 35-Internet.zip / dongrovs.zip / errorsto.cmd < prev    next >
OS/2 REXX Batch file  |  1996-10-16  |  4KB  |  147 lines

  1. /* ********************************* */
  2. /*   By: Jetnick Enterprise          */
  3. /*       Don E. Groves, Jr.          */
  4. /*   Contact Information:            */
  5. /*     E-mail: jetnick@erols.com     */
  6. /*        CIS: 71310,3702            */
  7. /* Date: 20 Sep 1996                 */
  8. /* ********************************* */
  9.  
  10. parse source . invhow myName
  11. RtCode = 0
  12. if invhow == 'COMMAND'
  13. THEN DO
  14.    RtCode = 1
  15.    Argv = .ARRAY_CLI~of(ARG(1), .false, .false) /* parse the arguments */
  16.    if Argv~items > 0
  17.    THEN DO
  18.       name = Argv[1]     /* get path to folder */
  19.       msg = .Load_Msg~new(name)
  20.       if msg~Good
  21.       THEN DO
  22.          fMsg = .Forward_Msg~NEW(msg,'jetnick@erols.com (Don E. Groves, Jr.)')
  23.          tmpName = 'ErrorsTo.RCV'
  24.          fh = .Stream~new(tmpName)
  25.          fh~Open('WRITE REPLACE')
  26.          su = fMsg~Supplier
  27.          do while su~Available
  28.             fh~LineOut(su~item)
  29.             su~next
  30.          END
  31.          fh~CLOSE
  32.          address CMD 'mr2i.exe /Q'~''(tmpName)
  33.       END
  34.       RtCode = 0
  35.    END
  36. END
  37. Return RtCode
  38.  
  39. ::requires Array_Cli
  40. ::requires MyTimeZone
  41.  
  42. ::class Forward_Msg
  43. ::method init
  44.   expose FlC
  45.   use arg msg, FromName
  46.   FlC = .List~NEW
  47.   Flc~insert('From:'~' '(FromName))
  48.   Flc~insert('Reply-to:'~' '(msg~replyTo))
  49.   Flc~insert('Date:'~' '(.MyTimeZone))
  50.   Flc~insert('To:'~' '(msg~msgTo))
  51.   Flc~insert('Subject:'~' '(msg~Subject))
  52.   Flc~insert('')
  53.   Flc~insert('')
  54.   Flc~insert('-------------------------------------------------------------------------')
  55.   Flc~insert('The following message is forwarded to you by'~' '(FromName))
  56.   Flc~insert('(listed as the From user of this message).')
  57.   Flc~insert('The original sender (see the header, below) was'~' '(msg~replyTo))
  58.   Flc~insert('and has been set as the "Reply-To" field of this message.')
  59.   Flc~insert('-------------------------------------------------------------------------')
  60.   su = msg~Supplier
  61.   do while su~Available
  62.      Flc~insert(su~item)
  63.      su~next
  64.   END
  65.   Flc~insert('-------------------------------------------------------------------------')
  66.   Flc~insert('-- End of forwarded message')
  67.   Flc~insert('-------------------------------------------------------------------------')
  68.   Flc~insert('')
  69.   Flc~insert('--')
  70.   Flc~insert('-----------------------------------------------------')
  71.   Flc~insert(FromName)
  72.   Flc~insert('-----------------------------------------------------')
  73.   Flc~insert('****->INSERT DATETIME<-****')
  74.   Flc~insert('****->INSERT TAG HERE<-****')
  75. return self
  76. ::method FlC
  77.   expose FlC
  78. return Flc
  79. ::method Supplier
  80.   expose FlC
  81. return Flc~Supplier
  82.  
  83. ::class Load_Msg
  84. ::method msgTo   Attribute
  85. ::method replyTo Attribute
  86. ::method Subject Attribute
  87. ::method Good Attribute
  88. ::method init
  89.   expose msg
  90.   use arg name
  91.   self~Good    = .false
  92.   self~msgTo   = .nil
  93.   self~replyTo = .nil
  94.   self~Subject = .nil
  95.   fh = .Stream~NEW(name)
  96.   fh~OPEN('READ BINARY')
  97.   msgdata = fh~CharIn(1, fh~Query('SIZE'))
  98.   fh~Close
  99.   drop fh
  100.   msg = .Array~New
  101.   DO WHILE msgData \= ''
  102.      wrk = ''
  103.      parse value msgData with wrk '0A'x msgData
  104.      msg[msg~Items + 1] = wrk~ChangeStr('0D'x,'')
  105.   end
  106.   drop msgdata
  107.   su = msg~Supplier
  108.   x = 0
  109.   do while su~Available
  110.      select
  111.        when su~item~length = 0
  112.        then LEAVE  /* Leave when end of header is reached */
  113.        When su~item~pos('From:',1) = 1
  114.        THEN DO
  115.           self~replyTo = su~item~SUBSTR(su~item~pos(':') + 1)~strip('L')
  116.           x = x + 1
  117.        END
  118.        When su~item~pos('Subject:',1) = 1
  119.        THEN DO
  120.           self~Subject = su~item~SUBSTR(su~item~pos(':') + 1)~strip('L')
  121.           x = x + 1
  122.        END
  123.        otherwise nop
  124.      end
  125.      su~next
  126.   end
  127.   if x = 2
  128.   THEN DO
  129.     /* Search the body for the Errors-to: string */
  130.     do while su~Available
  131.       IF su~item~pos('Errors-to:',1) = 1
  132.       THEN DO
  133.          self~msgTo = su~item~SUBSTR(su~item~pos(':') + 1)~strip('L')
  134.          x = x + 1
  135.          LEAVE
  136.        END
  137.        su~next
  138.     end
  139.   end
  140.   self~good = ( x = 3 )
  141. return self
  142. ::method Supplier
  143.   expose msg
  144. return msg~Supplier
  145.  
  146.  
  147.