How can I show images from a Microsoft.Graph.Models.Message in a WebBrowser in C#

96 Views Asked by At

I'm tryna show content of a Microsoft.Graph.Models.Message in a Web Browser. My issue is that in some messages I only have a bad error picture instead of the pic.

I try different things, last one is download the email to a temp folder and show from there but nothing works. Any suggestion? Thankyou.

private async void MostrarMensajeEnWebBrowser(Message message)
{
    emailWebBrowser.ScriptErrorsSuppressed = true;
    var gservice = new GraphService();
    var imapClient = new ImapMail(gservice);
    if (message.HasAttachments == true)
    {                
        string tempFilePath = Path.GetTempPath();
        tempFolder = tempFilePath;
        await imapClient.SaveAttachmentMail(message, tempFilePath); //Here I download all attachments        
    }
    await imapClient.SaveMail(mensaje, tempFolder);
    string pathEML = Path.Combine(tempFolder, message.Subject.Replace(":", "_").Replace("/", "_") + ".eml");
    MimeMessage msg = MimeMessage.Load(pathEML); ;
    string bodyHTML = msg.HtmlBody ?? msg.TextBody;
    
    emailWebBrowser.DocumentText = bodyHTML;
}
0

There are 0 best solutions below