0

I created a razor page that sends and email confirming to a group of users that a request has been made. When I look my inbox on the web or the windows email app, the mail looks jsut the way I want it. But the users use the outlook client to check on their emails and the mail looks way too different with the logo taking a whole table cell and the rest looks tiny. I use an alternate view to embbed the image but I don't know if the image is causin the problem or something else. Here's my code:

string contentID = Guid.NewGuid().ToString().Replace("-", "");
                        
                        tab = tab.Replace("/img/logo500.png", "cid:" + contentID);
                        
                        // tab = tab.Replace("<div id=\"divLinkAprob\"></div>", "<a href=http://localhost:999/SolicitudAdicionalesMP?op=" + op + "&lote=1121035&producto=" + producto.Replace(" ", "%20") + "&itemcode=" + itemCode + "&itemname=" + itemName.Replace(" ", "%20") + "&cantenvasada=" + cantEnvasada + "&cantasignada=" + cantAsignada + "&adicional=" + adicional + "&poradicional=" + porAdicional + "&motivo=" + motivo.Replace(" ", "%20") + "&tab=" + tab.Replace(" ", "%20") + ">APROBAR</a>");
                        tab = tab.Replace("<div id=\"enviadoPor\"></div>", "Aprobado por: " + usuario);
                        tab += "Aprobado por: " + usuario;

                        AlternateView htmlView = AlternateView.CreateAlternateViewFromString(tab, null, "text/html");
                        //path of image or stream
                        LinkedResource imagelink = new LinkedResource("wwwroot/img/logo500.png", "image/png");
                        imagelink.ContentId = contentID;
                        imagelink.TransferEncoding = System.Net.Mime.TransferEncoding.Base64;
                        htmlView.LinkedResources.Add(imagelink);
                        mail.AlternateViews.Add(htmlView);

Mail from microsoft mail app

Mail from outlook app 1

Mail from outlook app 2

  • Email clients will show html emails in many and varied ways. It will look different on gmail, outlook, or yahoo. That's just the way it is. If you look at some of the HTML generated by email templates like SurveyMonkey, you will see loads of email client specific hacks. – Neil Mar 02 '22 at 19:02
  • 1
    Does this answer your question? [Emails not rendering properly on outlook app but works on browser](https://stackoverflow.com/questions/67503489/emails-not-rendering-properly-on-outlook-app-but-works-on-browser) – phuzi Mar 02 '22 at 19:16

0 Answers0