title: perl imap move message to trash (Mail::IMAPClient)
body: <p>I need to move all messages from unseen to the trash(and delete then from inbox). </p>
  
  <pre><code>my $inbox = $imap-&gt;select("Inbox");
  my @mails = ( $imap-&gt;unseen );
  
  foreach my $msgid (@mails) {
      $imap-&gt;set_flag( "Deleted", @mails )
          or die "Could not set flag: $@\n";
  }
  </code></pre>
  
  <p>This code delete messages completely. (without expunge too)</p>
  
  <p>I tried to use "move" and "copy":</p>
  
  <pre><code>my $Trash = "Trash";
  my $newUid = $imap-&gt;move( $Trash, $msgid )
      or die "Could not move: $@\n";
  my $uidList = $imap-&gt;copy( $Trash, @mails )
      or die "Could not copy: $@\n";
  </code></pre>
  
  <p>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!</p>
  
  <p>i use <a href="https://metacpan.org/pod/Mail::IMAPClient" rel="nofollow"><code>Mail::IMAPClient</code></a></p>