# THIS IS THE HAMSTER-MAILHEADER-MODULE BY MDIEDRICH. # IT IS NEEDED FOR SOME OF MY SCRIPTS (LISTSERV, HAMREMOTE). # REVISION-DATE: 23.02.2001 - Rev. 1.05 # PLEASE LOOK AT http://www.mdiedrich.de FOR UPDATES AND MORE INFORMATION. ### SUB: EXTRACT ### sub mailhdr_extract(*$f,*$t,*$s,*$d,*$m,*$r,*$sd,*$o,*$fb) var($uninteresting) if( $filename == "" ) print( "$filename ist leer" ) return(1) endif # Read mailfile (complete eMail per line in List) VarSet( $input, ListAlloc ) if( ListLoad( $input, $filename ) < 0 ) print( "Fehler beim Öffnen der Datei " + $filename ) return(1) endif # GET Subject, From, Date, ... from *.msg-file # Read per line and work with and delete line after being used until # body is reached. VarSet( $z, "0" ) while( $z != "1" ) VarSet( $line, ListGet( $input, 0 ) ) if( RE_Match( $line, "^subject:\s+(.*)" ) ) RE_Parse( $line, "(\S+:)\s+(.*)", $uninteresting, $s ) endif if( RE_Match( $line, "^from:\s+(.*)" ) ) RE_Parse( $line, "(\S+:)\s+(.*)", $uninteresting, $f ) endif if( RE_Match( $line, "^to:\s+(.*)" ) ) RE_Parse( $line, "(\S+:)\s+(.*)", $uninteresting, $t ) endif if( RE_Match( $line, "^reply-to:\s+(.*)" ) ) RE_Parse( $line, "(\S+:)\s+(.*)", $uninteresting, $r ) endif if( RE_Match( $line, "^organization:\s+(.*)" ) ) RE_Parse( $line, "(\S+:)\s+(.*)", $uninteresting, $o ) endif if( RE_Match( $line, "^sender:\s+(.*)" ) ) RE_Parse( $line, "(\S+:)\s+(.*)", $uninteresting, $sd ) endif if( RE_Match( $line, "^date:\s+(.*)" ) ) RE_Parse( $line, "(\S+:)\s+(.*)", $uninteresting, $d ) endif if( RE_Match( $line, "^message-id:\s+(.*)" ) ) RE_Parse( $line, "(\S+:)\s+(.*)", $uninteresting, $m ) endif if( $line = ( "" ) ) VarSet( $fb, ListGet( $input, int( $z ) + 1 ) ) VarSet( $z, "1" ) endif ListDelete( $input, 0 ) endwhile # free memory ListFree( $input ) endsub ### SUB: SPLITSUBJECT ### sub mailhdr_splitsubject(*$l,*$r) if( RE_Match( $orgsubject, "(.*)-(.*)" )) RE_Parse( $orgsubject, "(.*)-(.*)", $l, $r ) return(0) else return(1) endif endsub