title: How can I strip HTML and attachments from emails?
body: <p>I am using the program below to sort and eventually print out email messages. Some messages may contain attachments or HTML code, which would not be good for printing. Is there an easy way to strip attachments and strip HTML but not the text formatted by HTML from the messages?</p>
  
  <pre><code>#!/usr/bin/perl
  use warnings;
  use strict;
  use Mail::Box::Manager;
  
  open (MYFILE, '&gt;&gt;data.txt');
  binmode(MYFILE, ':encoding(UTF-8)');
  
  
  my $file = shift || $ENV{MAIL};
  my $mgr = Mail::Box::Manager-&gt;new(
      access          =&gt; 'r',
  );
  
  my $folder = $mgr-&gt;open( folder =&gt; $file )
  or die "$file: Unable to open: $!\n";
  
  for my $msg ( sort { $a-&gt;timestamp &lt;=&gt; $b-&gt;timestamp } $folder-&gt;messages)
  {
      my $to          = join( ', ', map { $_-&gt;format } $msg-&gt;to );
      my $from        = join( ', ', map { $_-&gt;format } $msg-&gt;from );
      my $date        = localtime( $msg-&gt;timestamp );
      my $subject     = $msg-&gt;subject;
      my $body        = $msg-&gt;decoded-&gt;string;
  
      # Strip all quoted text
      $body =~ s/^&gt;.*$//msg;
  
      print MYFILE &lt;&lt;"";
  From: $from
  To: $to
  Date: $date
  Subject: $subject
  \n
  $body
  
  }
  </code></pre>