title: IMAP S22.IMAP copy messages between servers
body: <p>I'm maiking a tool to migrate acoounts between servers.</p>
  
  <p>I'm using S22.IMAP dll, but when I call to Client.CopyMessages(mailIDs, Client2.DefaultMailbox), it</p>
  
  <p>creates the messages in the initial account (duplicate the messages and no copy to the other account server)..</p>
  
  <p>Can anyone help me? thanks
  Here is my code:</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.ComponentModel;
  using System.Data;
  using System.Drawing;
  using System.Linq;
  using System.Text;
  using System.Windows.Forms;
  using S22.Imap;
  using System.Net.Mail;
  
  namespace ImapPrueba1
  {
      public partial class Form1 : Form
      {
          private static IEnumerable&lt;MailMessage&gt; messages;
          private static ImapClient imapClient = null;
          private static IEnumerable&lt;string&gt; mailboxes, mailboxes2;
          private static IEnumerable&lt;uint&gt; mailIDs;
          private static MailMessage mailMessage;
  
          public Form1()
          {
              InitializeComponent();
          }
  
          private void Form1_Load(object sender, EventArgs e)
          {
  
              using (ImapClient Client = new ImapClient("correo.correo.com", 993,
               "correo@correo.es", "xxxxxx", AuthMethod.Login, true))
              {
                  ImapClient Client2 = new ImapClient("correonuevo.correonuevo.com", 993,
                      "correo@correo.es", "xxxxxx", AuthMethod.Login, true);
                  mailboxes = Client.ListMailboxes();
                  string mailbox, mailbox2;
                  for (int i = 0; i &lt;  mailboxes.Count(); i++) {
                      mailbox = mailboxes.ElementAt(i);
                      Client.DefaultMailbox = mailbox;
                      mailIDs = Client.Search(SearchCondition.All());
                      messages = Client.GetMessages(mailIDs);
                      //check the folder isn't in the destiny
                      mailboxes2 = Client2.ListMailboxes();
                      IEnumerable&lt;string&gt; items = mailboxes2.Where(p =&gt; p.Equals(mailbox));
                      int total = items.Count();
                      if (total == 0)
                      {
                          // set the folder in the destiny
                          Client2.CreateMailbox(mailbox);
                      }
  
                      Client2.DefaultMailbox = mailbox;
                      if (mailIDs.Count() &gt; 0)
                      {
                          //copy to the destiny
                          Client.CopyMessages(mailIDs, Client2.DefaultMailbox);
                      }
  
  
                  }
  
                  label1.Text = "cambio";
              }
  
          }
  
  
  
      }
  }
  </code></pre>