InboxEmail GetInboxEmailFromSummary(IMessageSummary item) { var fromAddresses = new List <string>(); foreach (var address in item.Envelope.From) { fromAddresses.Add(((MailboxAddress)address).Address); } var toAddresses = new List <string>(); foreach (var address in item.Envelope.To) { toAddresses.Add(((MailboxAddress)address).Address); } var inboxEmail = new InboxEmail { Id = item.Envelope.MessageId, ArrivalTime = item.Date.UtcDateTime, From = string.Join(";", fromAddresses), To = string.Join(";", toAddresses), Subject = item.Envelope.Subject, PreviewText = HtmlUtility.ConvertToPlainText(item.PreviewText), UniqueId = item.UniqueId, IsRead = item.Flags.Value.HasFlag(MessageFlags.Seen) }; return(inboxEmail); }
public MailPreview(MailClientForm parentForm, InboxEmail inboxEmail) { InitializeComponent(); _parentForm = parentForm; tbFrom.Text = inboxEmail.From; tbTo.Text = inboxEmail.To; tbSubject.Text = inboxEmail.Subject; pictureBoxLoading.Visible = true; Task.Run(() => { var message = _parentForm.MailReceiver.GetEmail(EmailType.Inbox, inboxEmail.UniqueId); GetAttachments(message); if (!string.IsNullOrEmpty(message.HtmlBody)) { this.Invoke((Action)(() => webBrowserBody.DocumentText = message.HtmlBody)); this.Invoke((Action)(() => webBrowserBody.Visible = true)); } else if (!string.IsNullOrEmpty(message.TextBody)) { this.Invoke((Action)(() => tbBody.Text = message.TextBody)); } this.Invoke((Action)(() => pictureBoxLoading.Visible = false)); this.Invoke((Action)(() => pictureBoxLoading.Enabled = false)); _parentForm.MailReceiver.SetMessageSeen(EmailType.Inbox, inboxEmail.UniqueId); }); lbDate.Text = "Arrival Time: " + inboxEmail.ArrivalTime; }