home *** CD-ROM | disk | FTP | other *** search
/ Merciful 3 / Merciful_Release_3.bin / software / c / crashmailv1.22reg.lha / CrashMail / rexx / CC-All.rexx < prev    next >
OS/2 REXX Batch file  |  1995-05-01  |  2KB  |  94 lines

  1. /*  $VER: CC-All 0.82 (01.05.95)
  2.  
  3.         by Fredrik Bennison
  4.  
  5.         This script parses a message to All and generates <x> copies of the
  6.         message to a list of recipients.
  7.  
  8.         Syntax: rx CC-All.rexx <file>
  9.  
  10. */
  11.  
  12. IF ~SHOW(Libraries,'rexxsupport.library') THEN
  13.     IF ~ADDLIB("rexxsupport.library",0,-30,0) THEN EXIT
  14.  
  15. parse arg file
  16.  
  17. cfgpath="Mail:CrashMail/"
  18. inbpath="Mail:CrashMail/Inbound/"
  19.  
  20. toname=""
  21. toaddr=""
  22. fromname=""
  23. fromaddr=""
  24. subject=""
  25. x=0
  26.  
  27. call open('file',file,'R')
  28.  
  29. /* keep going */
  30.  
  31. kg=TRUE
  32.  
  33. do while kg=TRUE
  34.  str = readln('file')
  35.  
  36.  if eof('file') then do
  37.    kg=FALSE
  38.  end
  39.  else if length(str)=0 then do
  40.  
  41.    /* *** Empty line = End of header *** */
  42.  
  43.    kg=FALSE
  44.  end
  45.  else do
  46.    if left(str,5)="From:" then parse var str 'From: 'fromaddr'@'dummy' ('fromname')'
  47.    if left(str,3)="To:" then parse var str 'To: 'toaddr'@'dummy' ('toname')'
  48.    if left(str,8)="Subject:" then subject=right(str,length(str)-9)
  49.    if left(str,11)="X-Fido-Via" then do
  50.         x=x+1
  51.         Via.x='01'x||right(str,length(str)-7)
  52.    end
  53.  end
  54. end
  55.  
  56. call open('out','T:CC.out','W')
  57. call writeln('out','01'x||'PID: CC-All v0.82')
  58. call writeln('out','            *!  Message sent by CC-All v0.82 at '||toaddr||'  !*')
  59. call writeln('out','')
  60.  
  61. do while ~eof('file')
  62.     str = readln('file')
  63.     call writeln('out',str)
  64. end
  65.  
  66. if x>0 then
  67.    do a=1 to x
  68.       call writeln('out',Via.a)
  69.    end
  70.  
  71. call close('file')
  72. call close('out')
  73.  
  74. parse var toaddr zon':'net'/'node'.'point
  75.  
  76. cfgfile = cfgpath||zon||'.'||net||'.'||node||'.'||point||'.CC'
  77.  
  78. call open('cfg',cfgfile,'R')
  79.  
  80. str = readln('cfg')
  81.  
  82. do while ~eof('cfg')
  83.     parse var str toname' @ 'toaddr
  84.  
  85.     IF toaddr~=fromaddr THEN
  86.         address command 'Mail:CrashMail/CrashWrite FN "'fromname'" FA 'fromaddr' TN "'toname'" TA 'toaddr' SUBJ "'subject'" DIR 'inbpath' TEXT T:CC.out'
  87.     str = readln('cfg')
  88. end
  89.  
  90. call close('cfg')
  91. call delete("T:CC.out")
  92.  
  93. exit 0
  94.