// POP3: Get all messages in server (HostPOP) and after that, delete all od messages in that server public int GetMailPOPDelete(string FolderName, string HostPOP, int PortPOP, bool SSLSupport, string MailName, string PWstring) { if (!imapConnect()) return -1; //choose current folfer if (!imapClient.SelectMailbox(FolderName)) { // if folder is not exist, create new folder imapClient.CreateMailbox(FolderName); imapClient.SelectMailbox(FolderName); } MessageSet OLdMSSet = imapClient.Search("ALL", true); MailMan subpopClient = new MailMan(); if (!subpopClient.UnlockComponent("MAIL-TEAMBEAN_4895F76A292K")) return -1; // config info of pop server subpopClient.MailHost = HostPOP; subpopClient.MailPort = PortPOP; subpopClient.PopUsername = MailName; subpopClient.PopPassword = PWstring; if (SSLSupport) subpopClient.PopSsl = true; //SSL support else subpopClient.PopSsl = false; //connect without SSL support subpopClient.ConnectTimeout = 15; // defaulf timeout = 30, so when it can't connect, it's too slow EmailBundle colecMessageInfo = subpopClient.CopyMail(); //Copy all of mail in mailbox of pop server if (colecMessageInfo == null) //connect fail, or don't have any new message { imapDisconnect(); return -1; } else { //copy new message to folder on our server for (int i = 0; i < colecMessageInfo.MessageCount; i++) { Email msif = colecMessageInfo.GetEmail(i); imapClient.AppendMail(FolderName, msif); } } subpopClient.DeleteBundle(colecMessageInfo); //delete all messages on pop server // mark new message unread // it's a little complex here, contact me if you need support imapClient.SelectMailbox(FolderName); MessageSet NewMSSet = imapClient.Search("ALL", true); for (int i = 0; i < OLdMSSet.Count; i++) NewMSSet.RemoveId(OLdMSSet.GetId(i)); imapClient.SetFlags(NewMSSet, "Seen", 0); imapDisconnect(); return colecMessageInfo.MessageCount; }