# Problem with Sending attachments

**URL:** <https://www.ruby-forum.com/t/problem-with-sending-attachments/139869>\
**Category:** Rails\
**Created:** [June 8, 2008, 2:15pm UTC](https://www.ruby-forum.com/t/problem-with-sending-attachments/139869 "2008-06-08T14:15:27Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![ankit2584](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/51bf81/32.png) [@ankit2584](https://www.ruby-forum.com/u/ankit2584)\
**Post date:** [June 8, 2008, 2:15pm UTC](https://www.ruby-forum.com/t/problem-with-sending-attachments/139869/1 "2008-06-08T14:15:27Z")

</div>

def send\_mail(person,textarea,subject,attachment\_id)  
recipients person.email1  
cc person.email2

```
from "some email address"
subject subject
content_type "text/html"
body textarea

unless attachment_id.nil?
  @attachment = Attachment.find_by_id(attachment_id)
  filename = @attachment.filename.rstrip
  attachment @attachment.content_type do |a|
  a.filename = @attachment.filename
  a.body =

```

File.read(“c:\inetpub\event\public\data\#{filename}”)  
end  
end  
end

Hello Above is the code for sending attachment.  
Problems

1. Whenever i send an attachment, the attachment does not open in the  
recepients inbox.The recepient gets an exclaimation mark at the end of  
the filename in the attachment.

2. Also my email text (i.e body of the email) is in html format that  
does not appear in html format. If i remove the attachment part and set  
the content\_type to “text/html” then the text appears in html format.  
But i want to send text in html format and also the attachment.

I believe there is something wrong with the way i have written  
content\_type.  
Can anyone please help me.

Thank you.
