[pmmail-list] Rexx to save messages

J Seder pmmail-list@blueprintsoftwareworks.com
Fri, 26 Oct 2001 19:37:52 -0700 (PDT)


I've posted this before...  I use this Rexx file in conjunction with a
manual filter to organize my e-mail messages as members in zip
archives.  Thus, I have a file called letters.zip which contains
john.msg, janice.msg, steve.msg, and so on.  Each .msg file contains
all the e-mails I have exchanged with those people, nicely formatted.

To set this up, save the enclosed files (pmmzip.cmd and separator.dat)
into your PMMail program directory.  Create a new filter named
"Archive" with a condition that's always true (I have Search: <Whole
Message> for @).  Type=Manual.  There are two actions:
	User hook (foreground):	c:\tools\pmmail\pmmzip.cmd
	Delete message:	Local copy

To use this, highlight one or more messages and click with the right
mouse button.  Select Archive.  You'll get a popup command window. 
Enter the archive and member, i.e.:
	letters john
Your message will be appended to john.msg in letters.zip.  If you
highlight a bunch of messages, then you'll be prompted many times.  You
can copy and paste into the command window to save time and typing... 
Remember that clicking both buttons in a command prompt window does a
"paste".

If you enter
	letters john e
or	letters john edit
then an editor (I use kedit) is applied to john.msg after the new
message is concatenated, but before it's saved into the zip archive. 
This lets you clean things up, removing headers from, say, jokes. 
Also, I use editor macros to remove useless header data.

To avoid errors, you must create any zip file in advance.  Also, this
cmd file pauses before creating a new member.

Here's pmmzip.cmd:

/* Rexx script to add a message to a zip archive */
outpath = '\personal\mail'
arg fpath
say 'Enter zipfile member [edit]'
parse pull zipfile member editflag
do while member='' | member='*' | missingp(outpath'\'zipfile'.zip')
   say 'member='member
   say 'missingp('zipfile')=' missingp(zipfile)
   say 'Syntax is:   pmmzip  <zipfile> <member> [edit]'
   say 'where:'
   say '   <zipfile>   : Zip file in' outpath '- default=letters'
   say '   <member>    : Member of zipfile (.msg suffix assumed)'
   say ' Example:  pmmzip work    ibm1998'
   say ' Example:  pmmzip letters JohnDoe'
   say ' '
   say 'Enter zipfile member [edit]'
   parse pull zipfile member editflag
   end
'copy' fpath outpath'\temptemp.msg'
edit = 0
if editflag='edit' | editflag='e' then edit = 1
say 'Zipfile='zipfile
say ' Member='member
say 'Message='fpath
say '   Edit='edit
dpos = pos('.',member)
if dpos<>0 then do
   say 'Truncating' member'...'
   member = left(member, dpos-1)
   end
rmsg = 'add'
'cd' outpath
if rc<>0 then return rc
'unzip' zipfile  member'.msg'
if rc=0 then do
   /* We're appending to an existing member */
   'rename' member'.msg *.ms2'
   'copy' member'.ms2+separator.dat+temptemp.msg' member'.msg'
   'erase temptemp.msg *.ms2'
   rmsg = 'REPLACE'
   end
else do
   'rename temptemp.msg' member'.msg'       /* New member */
   rmsg = 'ADD'
   end
/* 'pause' */
if edit then call 'k.cmd' member'.msg'
if edit=1 | rmsg<>'REPLACE' then pause 'Hit any key to' rmsg
member'.msg'
'zip -m' zipfile  member'.msg'
/* 'pause' */
return

missingp:
arg fspec
say 'Exists?' fspec stream(fspec,'C','query exists')
if stream(fspec,'C','query exists')='' then return 1
return 0


And separator.dat:
-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-

- pmmail-list - The PMMail Dicussion List ---------------------------
To POST to the list, send your message to:
pmmail-list@blueprintsoftwareworks.com

To UNSUBSCRIBE, send a message to mdaemon@bmtmicro.com with the first 
line of the message body being...
UNSUBSCRIBE pmmail-list@blueprintsoftwareworks.com
---------------------------------------------------------------------