Esempio n. 1
0
        SentEmail GetSentEmailFromSummary(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 sentEmail = new SentEmail
            {
                Id          = item.Envelope.MessageId,
                SentTime    = item.Date.UtcDateTime,
                From        = string.Join(";", fromAddresses),
                To          = string.Join(";", toAddresses),
                Subject     = item.Envelope.Subject,
                UniqueId    = item.UniqueId,
                PreviewText = HtmlUtility.ConvertToPlainText(item.PreviewText),
                IsRead      = item.Flags.Value.HasFlag(MessageFlags.Seen)
            };

            return(sentEmail);
        }
Esempio n. 2
0
        public MailPreview(MailClientForm parentForm, SentEmail sentEmail)
        {
            InitializeComponent();

            _parentForm    = parentForm;
            tbFrom.Text    = sentEmail.From;
            tbTo.Text      = sentEmail.To;
            tbSubject.Text = sentEmail.Subject;

            pictureBoxLoading.Visible = true;

            Task.Run(() =>
            {
                var message = _parentForm.MailReceiver.GetEmail(EmailType.SentEmails, sentEmail.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.SentEmails, sentEmail.UniqueId);
            });

            lbDate.Text = "Sent Time: " + sentEmail.SentTime;
        }