punitpawar has asked for the wisdom of the Perl Monks concerning the following question:

Hello
I am struggling with trying to read the newest unread message from the gmail account
This is the code which I have written that will connect to gmail account and will read the total number of messages
But I am not able to figure out a way to read the latest unread message
Any help on this will be really appreciated
my $server = Net::IMAP::Simple->new( "imap.gmail.com", port => 993, use_ssl => 1 ) or die "Unable to connect to IMAP: $Net::IMAP::Simple::errstr\n +"; # login if(!$server->login($gmailUserName,$gmailPassword)){ print STDERR "Login failed: $!"; exit(64); } # select the desired folder my $number_of_messages = $server->select( 'Inbox' ); print "\nNumber of messages : $number_of_messages\n";

Replies are listed 'Best First'.
Re: How do I read messages from my gmail account
by $h4X4_|=73}{ (Monk) on Jul 09, 2016 at 09:29 UTC
Re: How do I read messages from my gmail account
by punitpawar (Sexton) on Jul 08, 2016 at 23:08 UTC
    What I am observing is that the newest message is not read. Sometimes gmail has to be refreshed to read the latest message that has just arrived.
    Not sure if there is any method that will do a refresh of the gmail account first ...

      Hello punitpawar,

      Are you saying that the unread message has arrived since the $server->select('Inbox') call was issued? If so, you may need to call $server->status('Inbox') to refresh the messages.

      Hope that helps,

      Athanasius <°(((><contra mundum Iustus alius egestas vitae, eros Piratica,