我正在使用一种工具来迁移服务器之间的协议。
我正在使用S22.IMAP dll,但是当我调用Client.CopyMessages(mailIDs,Client2.DefaultMailbox)时,它
在初始帐户中创建邮件(复制邮件而不复制到其他帐户服务器)..
任何人都可以帮助我吗?谢谢 这是我的代码:
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<MailMessage> messages;
private static ImapClient imapClient = null;
private static IEnumerable<string> mailboxes, mailboxes2;
private static IEnumerable<uint> 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 < 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<string> items = mailboxes2.Where(p => 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() > 0)
{
//copy to the destiny
Client.CopyMessages(mailIDs, Client2.DefaultMailbox);
}
}
label1.Text = "cambio";
}
}
}
}