Hacking Gmail

(Grace) #1

176 Part III — Conquering Gmail


Listing 11-5 (continued)

print “\n”;

$label = $labels[ $num - 1 ];
if ($label) {
$messages =
$gmail->get_messages( label => $label ); # get all
labeled messages

$id = 1;
$num = 0;
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 remove label\n”;
$num = <>;
print “\n”;

$message = @{$messages}[ $num - 1 ];
$msgid = $message->{“id”};
if ($msgid) { # check if
message id is OK
$gmail->edit_labels(
label => $label,
action => “remove”,
msgid => $msgid
);
print “removed label\n”;
}
}

And Now...


You should now be able to deal confidently with the mail inside Gmail. But what
of your address book? In the next chapter, you look at using the Perl API to com-
municate with the address book and to import and export your contacts.
Free download pdf