[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: getting text of message as resource variable



At the start of May, Earl Hood wrote in reply to me:

> > I guess I could parse the email messages myself and pass the
> > bodies in as environmental variables to MHonArc. This solution
> > still would have the problem of deciding which email message
> > corresponded with which MHonArc file name.

> .... I recommended leveraging the annotation feature to get the
> desired effect.  I.e. Pre-create an annotation for each message
> including the first few lines of a message and then use the
> $NOTE$ resource variable to include it in the index.

This turned out cleaner than I expected using the Mail::Box
modules, but I imagine the MIME::* suite allow the same sort of
thing.

        foreach my $mail ( $folder->messages )
        {
                my @body = $mail->decoded->lines;
                my $id = $mail->messageId;

                foreach ( @body[0 .. 4] )
                {
                        s/([^\w()'*~!.-])/sprintf '%%%02X', ord $1/eg
                }
                my $body = join( '%0D%0A', @body[0 .. 4] );

                mhonarc::process_input(        
                        "-annotate"  
                        , "-outdir" , "../temp/$list"
                        , "-notetext", $body
                        , $id
                );
        }

I get the body of the message and its id and URL-escape it and
pass it to MHonArc. I use the resource variable, $NOTE$ in my rcfile to
put the annotation in the right URL. The only thing I don't like
is having to URL escape the string myself, but there doesn't seem
to be any MHonArc resource that will do it for me. 

The other thing I don't like is the MIME garbage left in the body
after decoding, but I can't expect MHonArc to do that for me :-)

-- 
Greg Matheson               Learn a third language and 
Chinmin College             be born again, again.
                       
Taiwan Penpals Archive <URL: http://netcity.hinet.net/kurage>


[Index of Archives]     [Bugtraq]     [Yosemite News]     [Mhonarc Home]