/// <summary> /// Method for verify if the message match the filter criteria. /// </summary> /// <param name="mailMessage">The mail message object.</param> /// <returns>The bool value indicating if the message is filtered or not.</returns> public bool IsMessageFiltered(MailMessage mailMessage) { bool ret = false; // verify the from field. if (!ret && !this.From.Equals(string.Empty)) { if (!mailMessage.From.Contains(this.From)) { ret = true; } } // verify the to field. if (!ret && !this.To.Equals(string.Empty)) { if (!mailMessage.To.Contains(this.To)) { ret = true; } } // verify the subject field. if (!ret && !this.Subject.Equals(string.Empty)) { if (!mailMessage.Subject.Contains(this.Subject)) { ret = true; } } // verify the message body field. if (!ret && !this.Message.Equals(string.Empty)) { Facade facade = Facade.GetInstance(); string mailbox = MainForm.GetInstance().GetSelectedMailbox(); string body = facade.GetMessageBodyString(mailMessage, mailbox); if (!body.Contains(this.Message)) { ret = true; } } // verify the message sent date. if (!ret && !this.DateFrom.Equals(string.Empty) || !this.DateTo.Equals(string.Empty)) { DateTime dtFrom = DateTime.MinValue; DateTime dtTo = DateTime.MaxValue; DateTime.TryParse(this.DateFrom, out dtFrom); DateTime.TryParse(this.DateTo, out dtTo); if (mailMessage.SentDate < dtFrom || mailMessage.SentDate > dtTo) { ret = true; } } return(ret); }