public void DeleteMailMessageOfAccountById(MailboxAccount account, string messageId) { Pop3Client client = null; try { client = new Pop3Client(account.Username, account.Password, account.Server); client.OpenInbox(); while (client.NextEmail()) { string id = client.Date.Ticks.ToString(); bool result = client.DeleteEmail(); if (!result) { throw new ApplicationException("Mail message not deleted"); } } } finally { client.CloseConnection(); } }
/// <summary> /// Gets POP3 email. /// </summary> /// <returns></returns> private static List<OEmailLog> GetPOP3Mail() { OApplicationSetting applicationSetting = OApplicationSetting.Current; Pop3Client email = new Pop3Client(applicationSetting.EmailUserName, Security.Decrypt(applicationSetting.EmailPassword), applicationSetting.EmailServer, applicationSetting.EmailPort); List<OEmailLog> emailList = new List<OEmailLog>(); email.OpenInbox(); while (email.NextEmail()) { emailList.Add(OEmailLog.WriteToEmailLog(email.From, email.Subject, email.Body)); email.DeleteEmail(); } email.CloseConnection(); return emailList; }