Send Image Base64 to e-mail

Asked

Viewed 1,202 times

1

I am trying to send an email with an image in Base64. html is going however the image does not.

An example of how the message is mounted:

<p>Mensagem.</p><br><br><img style='max-height:200px; max-width: 700px; width:auto; height:auto;' src='data:image/jpeg;base64,/Base64DaMinhaImagem' alt='Não foi possível carregar a imagem'>

But the image is not going and not even her 'Alt' is appearing. If I try to play what the variable returns me and generate a manual html with it is showing the image correctly. I am trying to send to a gmail account and to an outlook.

  • According to this post of Soen, it is not possible to use because these customers ignore images in Base64: https://stackoverflow.com/a/13051136/7762411, but the link that directs to the explanation no longer works, so I can not guarantee.

1 answer

3

Other people’s inbox is sacred.

Let me repeat again, now with emphasis. Other people’s inbox is sacred..

I guess I’m not clear enough.

OTHER PEOPLE’S INBOX IS SACRED!


If you host an image somewhere and send an email with the image address in the html, you sent a string. With UTF encoding this does not give more than six bytes per character, so even a long URL will not get to weigh a Kilobyte in the user input box.

But if you send a 10-megabyte image encoded as Base64, it’s like you sent a 10-megabyte attachment to the email. If every email image were encoded like this, there wouldn’t be enough storage in the world to save all the inboxes.

Depending on the moral and education of the person, an image encoded as Base64 in an email can be seen as a gaffe, an offense or even an attack. I was raised to think it was a police matter.

For this reason, the support of several email clients for Base64 - not only Gmail, but also Yahoo! and others - has varied over the years. So if you use this technique, your results will vary. You’ll never be sure if it’s going to work, and when it is, you won’t be sure if it’s going to work the next day. For online customers, a picture shown today may no longer appear in a few months.

So, if you want to keep sending image emails automatically, host your images somewhere. Besides being better for the user is quieter for you to give maintenance.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.