my $parsed = Email::MIME->new($message) or die "Could not parse email message: $!"; #$message is full text of entire email m\ essage foreach my $part ($parsed->parts) { if ($part->content_type =~ /text\/plain/i) { #You have a plain text part #Do stuff here with $part->body } elsif ($part->content_type =~ /image\/jpeg/i) { #You have a JPEG part #in $part->body } elsif ($part->content_type =~ /text\/html/i) { #You have an HTML part #in part body my $html = $part->body; my $plain_text; my $parsed_text = HTML::TokeParser->new(\$html) or die "Cannot read message text for parsing and cleaning: $!"; while (my $token = $parsed_text->get_token) { if ($token->[0] eq 'T') { # text $plain_text .= $token->[1]; } } #Do stuff with $plain_text extracted from HTML here } }