# Extracting Email Attachment Content

**URL:** <https://www.ruby-forum.com/t/extracting-email-attachment-content/59106>\
**Category:** Rails\
**Created:** [April 28, 2006, 6:12pm UTC](https://www.ruby-forum.com/t/extracting-email-attachment-content/59106 "2006-04-28T18:12:36Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![nmotter](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/f0a364/32.png) [@nmotter](https://www.ruby-forum.com/u/nmotter)\
**Post date:** [April 28, 2006, 6:12pm UTC](https://www.ruby-forum.com/t/extracting-email-attachment-content/59106/1 "2006-04-28T18:12:36Z")

</div>

If an email incoming to Actionmailer has an .htm attachment, how is it  
possible to extract the file’s text (the html text in the file) to  
insert into the database?

I’ve tried reading the attachment like so, theFile =  
File.open(attachment.read, “r”), to no avail. But that fails stating  
that there is no such file or directory (but the attachment is there for  
certain).

Any suggestions would be terribly appreciated.

Nathan M.

Operations Director

Northeast Region

Pilgrim IT, LLC

NORTHEAST OFFICE

1 Short Street

Northampton, MA 01060

TEL 413.517.5010 x201

FAX 413.587.0572

NOTICE: This email and any attachments are intended only for the  
addressee and may contain information that is confidential and/or  
legally privileged. If you are not the intended recipient or have  
received this email in error, please notify the sender by return email  
or by calling 866-434-4976. You should then delete the message and any  
attachments or copies. If you are not the intended recipient, you are  
prohibited from retaining, distributing, disclosing or using any  
information contained herein.
