The issue is that you are using:
$imap->top($i)
From the documentation (emphasis mine):
This method accepts a message number as its required parameter. That message will be retrieved from the currently selected folder. On success this method returns a list reference containing the lines of the header. Nothing is returned on failure and the errstr() error handler is set with the error message.
top
doesn't return the body of the message. You'll need to use get
for that. Something like this:
my $es = Email::Simple->new( join '', @{ $imap->get($i) } );
^^^