Search code examples
c#imagebase64mailmessage

An image with base64 source won't display properly in email's body


I send email like HTML with option IsBodyHtml = true.

var msg = new MailMessage(fromEmail, firstEmail, email.Subject, bodyText)
{
    IsBodyHtml = true
};

Where bodyText is TinyMCE editor parsed HTML that looks absolutly fine.

When I get email I see a normal formatted HTML and image like this one

<img src="data:image/jpeg;base64,/9j/4AAQSkZJRgABAQEASABIAAD/4Ug8RXhpZgAATU0AKgAAAAgABwALAAIAAAAmAAAIbgESAAMAAAABAAEAAAExAAIAAAAmAAAIlAEyAAIAAAAUAAAIuodpAAQAAAABAAAIzoglAAQAAAABAAARJuocAAcAAAgMAAAAYgAAIaYc6gAAAAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA ..... and etc ...." >

So it seems like the image which has base64 source wasn't encoded properly at all.

Please, help to fix it.

Thanks!

UPDATE #1 In Gmail it looks like this enter image description here

In the database it looks like enter image description here


Solution

  • https://www.google.com/search?q=does+gmail+display+base64&rlz=1C1GCEU_ruRU819RU819&oq=does+gmail+display+base64&aqs=chrome..69i57j33.6352j0j7&sourceid=chrome&ie=UTF-8

    2 Answers. base64 encoded images are not well supported in email. They aren't supported in most web email clients (including Gmail) and are completely blocked in Outlook. Apple Mail is one of the few clients that does support them, that's why you're able to see them there but not elsewhere.Nov 18, 2019