sub get_text_parts { my @parts = shift->parts; my %ct; # $ct{$_->content_type} = $_ for @parts; for (@parts) { (my $c = $_->content_type) =~ s/;.+//; # print "\nDEBUG: $c\n"; $ct{$c} = $_; } return $ct{'text/plain'} if exists $ct{'text/plain'}; return $ct{'text/html'} if exists $ct{'text/html'}; return $parts[0] if $which =~ /text/; return $parts[1] if $which =~ /html/; }