Search code examples
ruby-on-railsactionmailermailto

Open default email client (outlook, thunderbird, gmail, etc.) with attachment


I looked at a bunch of tutorials using ActionMailer, but they all seem to just automatically send emails without opening up a default email app. I want the user to be able to click a button that opens up their default email client with the to and subject fields filled in, and be able to have a file attached. Ideally, I want it to work just like:

<a href='mailto:[email protected]'>

but have it able to attach a file. I would post code, but I have no idea what to post. I guess the main question is if there's a way to get ActionMailer to open up outlook instead of just sending emails?

There is very similar question, Rails actionmailer open host email app but the solutions didn't work.

update

My app is for a small workplace where every computer has access to whatever files are needed which would be located on the server. I am trying to make it so that the user of the app can click an email button which grabs a pdf file from a folder on the server and opens up outlook on their machine with the file automatically attached.


Solution

  • Okay, it seems you can't use the mailto shell to add attachments from what google has told me BUT:

    The way I'd approach it is through a client side script or executable and the serverside trigger (the button on a website).

    I'd personally use a compiled autohotkey script but here is the link to a vbs/vba script (only works with outlook).

    Hope this points you in the right direction :)