# Attachments using actionmailer

**URL:** <https://www.ruby-forum.com/t/attachments-using-actionmailer/139763>\
**Category:** Rails\
**Created:** [June 6, 2008, 8:28pm UTC](https://www.ruby-forum.com/t/attachments-using-actionmailer/139763 "2008-06-06T20:28:10Z")\
**Posts on this page:** 2\
**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 6, 2008, 8:28pm UTC](https://www.ruby-forum.com/t/attachments-using-actionmailer/139763/1 "2008-06-06T20:28:10Z")

</div>

Hello,  
I have seen examples for attachment using action mailer in rails.  
They all say that you need to mention the content type of the file type  
attached and in the exmaple they give the content type explicitly(i.e  
static in code).

What i need is how can i find the content/type of the file dynamically.  
This is because i wont come to know which file the user will be  
attaching…

The other problem is that if you clicked on the attachment browse button  
and have attached a file by mistake there is no way to deattach the  
file. SO the install.log has now been attached throgh my post by mistake  
but i cannot remove it.

Please help

Thank you.

---

<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 6, 2008, 10:06pm UTC](https://www.ruby-forum.com/t/attachments-using-actionmailer/139763/2 "2008-06-06T22:06:24Z")

</div>

I think the mime-types gem is what you want:

sudo gem install mime-types

api docs are here:  
[http://mime-types.rubyforge.org/](http://mime-types.rubyforge.org/)
