Exemple #1
0
        /// Met à jour l'interface pour afficher le contenu d'un email
        private void ShowCurrentMail()
        {
            if (currentCompteMessagerie.isAuthenticated())
            {
                if (this.gCurrentMail != null)
                {
                    showMailControls();
                    //From
                    foreach (var vFrom in gCurrentMail.From.Mailboxes)
                    {
                        I_CurrentMailFrom.Text = I_CurrentMailFrom.Text + vFrom.Address + "  ";
                    }
                    I_CurrentMailTo.Text = gCurrentMail.To.ToString();
                    //Cc
                    foreach (InternetAddress vCc in gCurrentMail.Cc.Mailboxes)
                    {
                        I_CurrentMailCc.Text = I_CurrentMailCc.Text + "  " + vCc;
                    }
                    I_CurrentMailSubject.Text = gCurrentMail.Subject.ToString();
                    //Body
                    if (gCurrentMail.HtmlBody != null || gCurrentMail.TextBody != null)
                    {
                        if (gCurrentMail.HtmlBody != null)
                        {
                            WB_CurrentMailBody.NavigateToString(gCurrentMail.HtmlBody);
                        }
                        else
                        {
                            MemoryStream ms = new MemoryStream(UTF8Encoding.Default.GetBytes(gCurrentMail.TextBody));
                            WB_CurrentMailBody.NavigateToStream(ms);
                        }
                    }
                    else
                    {
                        //using (var stream = new MemoryStream())
                        //{
                        //    //gCurrentMail.WriteTo(stream);
                        //    //var encoding = Encoding.GetEncoding(28591);
                        //    //var Bytes = stream.GetBuffer();
                        //    //encoding.GetString(Bytes, 0, Bytes.Length);
                        //    //WB_CurrentMailBody.NavigateToStream(stream);

                        //}
                        string MessageText = gCurrentMail.GetTextBody(TextFormat.Html);
                        if (MessageText == null)
                        {
                            MessageText = "No Text.";
                        }
                        MemoryStream ms = new MemoryStream(UTF8Encoding.Default.GetBytes(MessageText));
                        WB_CurrentMailBody.NavigateToStream(ms);
                    }
                    this.L_CurrentMailDateTime.Content = "Reçu le " + gCurrentMail.Date.Date.ToShortDateString() + " à " + gCurrentMail.Date.DateTime.ToShortTimeString();
                    // PJ
                    if (gCurrentMail.Attachments.Count() > 0)
                    {
                        I_CurrentMailPj.Content = gCurrentMail.Attachments.Count() + " pièce(s) jointe(s).";
                    }
                }
            }
        }