# Binary image and email

**URL:** <https://www.ruby-forum.com/t/binary-image-and-email/179096>\
**Category:** Rails\
**Created:** [November 17, 2009, 3:14pm UTC](https://www.ruby-forum.com/t/binary-image-and-email/179096 "2009-11-17T15:14:45Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![lune9](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/e79b87/32.png) [@lune9](https://www.ruby-forum.com/u/lune9)\
**Post date:** [November 17, 2009, 3:14pm UTC](https://www.ruby-forum.com/t/binary-image-and-email/179096/1 "2009-11-17T15:14:45Z")

</div>

Hi,

I generate graphs in Flash (with open flash charts) that I convert in a  
binary image. Then I send the source in an email but I don’t have the  
image in the mail.

The content type of the mail is “text/html”. Do I have to put something  
else?

What can I do to have my binary image correctly in my email?

Thank you

---

<div class="post-metadata">

**Author:** ![lune9](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/e79b87/32.png) [@lune9](https://www.ruby-forum.com/u/lune9)\
**Post date:** [November 17, 2009, 8:30pm UTC](https://www.ruby-forum.com/t/binary-image-and-email/179096/2 "2009-11-17T20:30:12Z")

</div>

Lune L. wrote:

> What can I do to have my binary image correctly in my email?

Try something like suggested here:

> <https://stackoverflow.com/questions/525256/how-to-embed-images-in-html-email-on-the-mail-server>

---

<div class="post-metadata">

**Author:** ![lune9](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/e79b87/32.png) [@lune9](https://www.ruby-forum.com/u/lune9)\
**Post date:** [November 18, 2009, 11:09am UTC](https://www.ruby-forum.com/t/binary-image-and-email/179096/3 "2009-11-18T11:09:56Z")

</div>

Robert W. wrote:

> Robert W. wrote:
> 
> > Try something like suggested here:  
> > [How to embed images in HTML email on the mail server? - Stack Overflow](http://stackoverflow.com/questions/525256/how-to-embed-images-in-html-email-on-the-mail-server)
> 
> Note that, as mentioned a few times in the above discussion, I don’t  
> advocate this solution. Whenever I need to do something like this I  
> provide absolute URLs for my HTML images so the email clients can  
> retrieve the images from my web server. This does not require embedding  
> the binary images in the HTML email.
> 
> Take note also that that embedding approach may not even work in all  
> email clients. Also be aware that some HTML email clients are configured  
> to block rendering of images in HTML email due to security  
> considerations. Taking advantage of image rendering bugs is a common  
> exploit for spreading viruses. This is why they are so commonly blocked  
> as either attachments or ![]() tag sources.

I wanted to avoid to save images on the server but it seems I don’t have  
the choice.

What do you think if I generate a pdf where I can put my binary images  
in it and send the pdf in attachment to the mail. Do you know a ruby  
library which accepts binary images ?

---

<div class="post-metadata">

**Author:** ![lune9](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/e79b87/32.png) [@lune9](https://www.ruby-forum.com/u/lune9)\
**Post date:** [November 17, 2009, 8:41pm UTC](https://www.ruby-forum.com/t/binary-image-and-email/179096/4 "2009-11-17T20:41:16Z")

</div>

Robert W. wrote:

> Try something like suggested here:  
> [How to embed images in HTML email on the mail server? - Stack Overflow](http://stackoverflow.com/questions/525256/how-to-embed-images-in-html-email-on-the-mail-server)

Note that, as mentioned a few times in the above discussion, I don’t  
advocate this solution. Whenever I need to do something like this I  
provide absolute URLs for my HTML images so the email clients can  
retrieve the images from my web server. This does not require embedding  
the binary images in the HTML email.

Take note also that that embedding approach may not even work in all  
email clients. Also be aware that some HTML email clients are configured  
to block rendering of images in HTML email due to security  
considerations. Taking advantage of image rendering bugs is a common  
exploit for spreading viruses. This is why they are so commonly blocked  
as either attachments or ![]() tag sources.

---

<div class="post-metadata">

**Author:** ![lune9](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/e79b87/32.png) [@lune9](https://www.ruby-forum.com/u/lune9)\
**Post date:** [November 19, 2009, 5:32pm UTC](https://www.ruby-forum.com/t/binary-image-and-email/179096/5 "2009-11-19T17:32:29Z")

</div>

Lune L. wrote:

> What do you think if I generate a pdf where I can put my binary images  
> in it and send the pdf in attachment to the mail. Do you know a ruby  
> library which accepts binary images ?

[http://prawn.majesticseacreature.com/](http://prawn.majesticseacreature.com/)
