# Ruby + IMAP + Attachment

**URL:** <https://www.ruby-forum.com/t/ruby-imap-attachment/65609>\
**Category:** Ruby\
**Created:** [August 19, 2006, 6:50pm UTC](https://www.ruby-forum.com/t/ruby-imap-attachment/65609 "2006-08-19T18:50:00Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![stian](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/3be4f8/32.png) [@stian](https://www.ruby-forum.com/u/stian)\
**Post date:** [August 19, 2006, 6:50pm UTC](https://www.ruby-forum.com/t/ruby-imap-attachment/65609/1 "2006-08-19T18:50:00Z")

</div>

I am trying read out attachments using Net::IMAP, but this seems to be  
going nowhere. Docs make no mention of such, and I am at a loss on where  
to actually begin. I can read messages and such using Net::IMAP, even  
got the filenavn of the attachment, but not the data for it, and thus  
not able to store it as file or in a database.

Any suggestions?

Best regards,  
Stian

---

<div class="post-metadata">

**Author:** ![stian](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/3be4f8/32.png) [@stian](https://www.ruby-forum.com/u/stian)\
**Post date:** [August 19, 2006, 7:09pm UTC](https://www.ruby-forum.com/t/ruby-imap-attachment/65609/2 "2006-08-19T19:09:18Z")

</div>

> > > > > “S” == Stian H. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) writes:

S\> I am trying read out attachments using Net::IMAP, but this seems to  
be  
S\> going nowhere. Docs make no mention of such, and I am at a loss on  
where  
S\> to actually begin. I can read messages and such using Net::IMAP, even  
S\> got the filenavn of the attachment, but not the data for it, and thus  
S\> not able to store it as file or in a database.

You have an example in comp.lang.ruby

Search the thread “Retrieve email attachments using Net::IMAP” in  
google

Basically when you have a message id, you can do

image.fetch(message\_id, “BODY[1]”)  
image.fetch(message\_id, “BODY[2]”)

Guy Decoux
