private void initialize(IMessage serverMailItem) { _id = serverMailItem.Id; //If HTML, take text. Otherwise, use content as is string bodyContent = serverMailItem.Body.Content; if (serverMailItem.Body.ContentType == BodyType.HTML) { bodyContent = HtmlUtilities.ConvertToText(bodyContent); } _body = bodyContent; _subject = serverMailItem.Subject; _recipients = _mailOperations.BuildRecipientList(serverMailItem.ToRecipients); if (serverMailItem.Sender != null) { _sender = serverMailItem.Sender.EmailAddress.Address; } else { _sender = string.Empty; // Sometimes, mails exist as draft, and therefore haven't been sent. } if (serverMailItem.DateTimeReceived != null) { _received = serverMailItem.DateTimeReceived; } _displayString = _received + ": " + _sender + ":: " + _subject; }
public MailItem(IMessage serverMailItem) { IsLastItem = false; IsFirstItem = false; ID = serverMailItem.Id; //If HTML, take text. Otherwise, use content as is string bodyType = serverMailItem.Body.ContentType.ToString(); string bodyContent = serverMailItem.Body.Content; if (bodyType == "HTML") { bodyContent = Regex.Replace(bodyContent, "<[^>]*>", ""); bodyContent = Regex.Replace(bodyContent, "\n", ""); bodyContent = Regex.Replace(bodyContent, "\r", ""); } Body = bodyContent; Subject = serverMailItem.Subject; Recipients = _mailOperations.BuildRecipientList(serverMailItem.ToRecipients); if (serverMailItem.Sender != null) { Sender = serverMailItem.Sender.EmailAddress.Address; } else { Sender = string.Empty; // Sometimes, mails exist as draft, and therefore haven't been sent. } if (serverMailItem.DateTimeReceived != null) { Received = serverMailItem.DateTimeReceived; } }