From: Joseph Polanik
David Appelbaum suggested saving emails to text and writing macros to strip
away trash and to do whatever else is desired.
James Sewell replied
>The only difficulty is that according to the RFC, which is the
>"standard ruleset" for mail, the headers may appear in any order.
>This means it is hard to identify the start of a mail message since
>you can't depend on the first header being "TO:" for instance.
We have come full circle. Some mail clients will always put a certain
header line first although the others might not always be in the same
order. Eudora, for example, puts the Return-Path: line first.
Perhaps not all mail clients will do this. The solutions are the same as
were discussed with regard to filtering:
A. Stop complaining and learn to live with a substandard mail client;
B. Get a superior mail client; or
C. Write a macro that will have TSE do what needs doing.
>If anyone has some macros to deal with mail messages perhaps it
>would be beneficial to post them to the ftp site and let us know
>they are there on this list. I've often considered such a thing
>but don't have the time to work out the details so I would be
>interested.
Am I being diss'ed or something?
A few days ago I posted the entire text of a macro I called 'The Stripper'
that you can cut and paste into TSE and customize for your mail client and
individual needs.
Let me point out that as long as your mail client always has a particular
line first the rest doesn't matter.
For reasons having to do with how I intend to store the saved mail (I want
it to end up in InfoSelect(tm), a random information manager), I want the
subject line to be the first line of each msg. As a result, I've set the
stripper to wipe out all but the Date, From and Subject lines.
Once in a while this leaves the subject line first, but usually it doesn't.
So ... instead of asking the world to adopt a browser/mail client that put
the subject first, I endowed the stripper with a procedure that ... Moved
... The ... Subject ... Line ... To ... Where ... I ... Wanted ... It.
For those who might be interested, here she is again.
//Declarations
string HeaderStart[7] = "Testing"
forward proc PurgeHeader()
forward proc PurgeMoveSubjLine()
forward proc PurgeDateFrom()
proc mStripper()
Set (Break, ON)
Set (WordWrap, OFF)
BegFile()
HeaderStart = GetText(1, 7) //Identify the start of a Msg
repeat
If Find(HeaderStart, "X^")
BegLine()
InsertLine(Format('~')) //Prepares file for InfoSelect
Down()
KillLine()
PurgeHeader()
PurgeMoveSubjLine()
PurgeDateFrom()
endif
until not Down()
BegFile()
KillLine()
Set (WordWrap, ON)
end mStripper
mStripper()
//Wipe out a variable number of characters
proc Purge(integer i)
while i
DelChar()
i = i - 1
endwhile
end
//Wipe out all but 'Date', 'From' and 'Subject' lines
proc PurgeHeader()
STRING TestString[5] = "Test:"
BegLine()
While iif(EndLine(),BegLine(),BegLine())
TestString = GetText(1, 5)
case TestString
when "Date:"
Down()
when "From:"
Down()
when "Subje"
Down()
otherwise
KillLine()
endcase
endwhile
end
//Make Subject line the first line of each msg
proc PurgeMoveSubjLine()
BegLine()
while Chr(CurrChar()) "S" //Locate Subject line
Up()
endwhile
Purge(9) //Wipes out the string 'Subject: '
DelLine() //Move to the Line following the '~'
repeat
Up()
until Chr(CurrChar()) == '~'
Down()
InsertLine()
Undelete() //Inserts line and its original CR
end
/*************************** PurgeDateFrom *************
Purges all but DD Mmm YY from the date line and all but name and
email address from "From:" line
Handles two formats:
Date: Sun, 22 Jun 97 18:25:17 PDT and
Date: 22 Jun 97 18:25:17 PDT
****************************************************************/
proc PurgeDateFrom()
STRING TestString[5] = "Test:"
string TestDigit[2] = "ZZ"
INTEGER Twice = 2
integer k = 3
BegLine()
while Twice //Purge 2 lines (Date & From)
TestString = GetText(1, 5)
If TestString == "Date:"
Twice = Twice - 1
Purge(6) //delete "Date: "
TestDigit = GetText(1, 2)
If not Val(TestDigit) //Detects DOW
Purge(5) //Purges if Present
endif
while k
NextChar()
if IsWhite() //skip DD mmm YY components
k = k - 1
endif
endwhile
DelToEol()
BegLine()
elseif TestString == "From:"
Purge(6)
Twice = Twice - 1
endif
Down()
endwhile
Down() // Add extra line after header
InsertLine()
end
/*****************************************************************************
Note 1: Inserting a '~' [tilde] at the beginning of each note prepares the
stripped file for importation by InfoSelect which treats the tilde as a
signal to start a new note.
Note 2: I don't sell InfoSelect nor work for its maker (MicroLogic). I just
use it.
Note 3: Stripper may not remove header lines that aren't in the msg header
as when they are part of a quoted msg.
Note 4: Stripper may have to be customized for different browsers or for
different types of lists or for msgs containing a list's archive files. I'd
appreciate hearing how you customize this macro.
****************************************************************************
***/
---
---------------
* Origin: apana>>>>>fidonet [sawasdi.apana.org.au] (3:800/846.13)
|