172 Part III — Conquering Gmail
Listing 11-3 (continued)
}
print “\n”;
print “enter label number to retrive labeled messages:\n”;
$num = <>;
print “\n”;
$label = $labels[ $num - 1 ];
if ($label) {
$messages =
$gmail->get_messages( label => $label ); # get all
labeled messages
$id = 1;
foreach ( @{$messages} ) { # and iterate through them
print $id. “\t”
. $_->{“sender_email”}. “\t”
. stripbold( $->{“subject”} )
. “\n”; # output message data
$id++;
}
print “\n”;
print “enter message number to reply to\n”;
$num = <>;
print “\n”;
$message = @{$messages}[ $num - 1 ];
$msgid = $message->{“id”};
if ($msgid) { # check if message id is OK
print “body:\n”;
$body = <>;
$gmail->send_message(
to => $message->{“sender_email”},
subject => “Re: “. strip_bold( $message-
>{“subject”} ),
msgbody => $body
); # we are using sender and subject from the
original message
print “message sent\n”;
}
}