I need to move all messages from unseen to the trash(and delete then from inbox).
my $inbox = $imap->select("Inbox");
my @mails = ( $imap->unseen );
foreach my $msgid (@mails) {
$imap->set_flag( "Deleted", @mails )
or die "Could not set flag: $@\n";
}
This code delete messages completely. (without expunge too)
I tried to use "move" and "copy":
my $Trash = "Trash";
my $newUid = $imap->move( $Trash, $msgid )
or die "Could not move: $@\n";
my $uidList = $imap->copy( $Trash, @mails )
or die "Could not copy: $@\n";
But "move" create new mark(folder) and "copy" dont work "Could not copy: 6 NO [TRYCREATE] No folder Trash (Failure)" I tried to use name: /Trash, [imap]Trash etc., similar results. This must work for different mail services!
i use Mail::IMAPClient