# Read attached document from .eml file

**URL:** <https://www.ruby-forum.com/t/read-attached-document-from-eml-file/178060>\
**Category:** Ruby\
**Created:** [October 28, 2009, 5:12pm UTC](https://www.ruby-forum.com/t/read-attached-document-from-eml-file/178060 "2009-10-28T17:12:39Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![itkin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/22d042/32.png) [@itkin](https://www.ruby-forum.com/u/itkin)\
**Post date:** [October 28, 2009, 5:12pm UTC](https://www.ruby-forum.com/t/read-attached-document-from-eml-file/178060/1 "2009-10-28T17:12:39Z")

</div>

Hi,

I have to read .eml file with ruby in order to get and extract  
attachements, does anything exist on this subject ?

Thanks in advance ,

Nicolas

---

<div class="post-metadata">

**Author:** ![itkin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/22d042/32.png) [@itkin](https://www.ruby-forum.com/u/itkin)\
**Post date:** [October 28, 2009, 5:41pm UTC](https://www.ruby-forum.com/t/read-attached-document-from-eml-file/178060/2 "2009-10-28T17:41:16Z")

</div>

nico itkin wrote:

> I have to read .eml file with ruby in order to get and extract  
> attachements, does anything exist on this subject ?

Did you google “ruby eml”? What did you make of the projects that turns  
up?

---

<div class="post-metadata">

**Author:** ![itkin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/22d042/32.png) [@itkin](https://www.ruby-forum.com/u/itkin)\
**Post date:** [October 29, 2009, 11:57am UTC](https://www.ruby-forum.com/t/read-attached-document-from-eml-file/178060/3 "2009-10-29T11:57:32Z")

</div>

nico itkin wrote:

> Hi,
> 
> I have to read .eml file with ruby in order to get and extract  
> attachements, does anything exist on this subject ?
> 
> Thanks in advance ,
> 
> Nicolas

Nothing much, there is only projects dealing with conversion from msg to  
eml or other email format.

Well an eml file is just a raw data email , so you can parse it with the  
rails method Tmail::Mail.parse(raw\_data).

When the .eml file had been generated from a MAC, you need to exchange  
\r by \n otherwise rails understands it as a single line file.

That’s it ! thanks for your answer !!

Nico
