Forum: Ruby on Rails Sending Documents via ActionMailer

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Ste H. (Guest)
on 2006-03-08 18:14
Hi,

I've been trying to set up to send already generated PDF's via the
ActionMailer class however it dosn't seem to send the full file. So when
I try to load the file after being sent it via email it dosn't because
it is corrupt. When I choose to send HTML instead it sends fine but it
dosn't work with Word Documents either

Do I need to do anything special for other file types?

Thanks
Ste H. (Guest)
on 2006-03-09 10:53
Bump?
Ste H. (Guest)
on 2006-03-11 20:44
no-one? I've tried everything it seems and dosnt seem to be doing
anything
James B. (Guest)
on 2006-03-13 00:20
(Received via mailing list)
Ste H. wrote:
> no-one? I've tried everything it seems and dosnt seem to be doing
> anything

Sadly, this seems to be another one of those poorly-documented Rails
scenarios.

I managed to send a PDF attachment with a text E-mail message for a
project that has since been put on hold (so I haven't run the code in
two months, and don't recall just how well it worked).

This is a method from my ActionMailer-derived class

   def pdf_invoice mail_params, pdf
     recipients  mail_params[ :to ]
     cc          mail_params[ :cc ]
     from        mail_params[ :user_email ]
     subject     mail_params[ :subject ]

     part :content_type => "text/plain",
          :body => render_message( 'pdf_invoice.text.plain',
                                    :note => mail_params[ :note ]  )


     attachment :content_type => "application/pdf",
        :filename => mail_params[ :base_filename ].to_s + '.pdf',
        :body => pdf

   end





--
James B.

Judge a man by his questions, rather than his answers.
  - Voltaire
Guest (Guest)
on 2006-03-13 16:05
Hi James thanks for the email, unfortunatly its not suitable for what I
need. For each item in my database has a PDF file already created and I
want to be able to automatically send the PDF attachment by a single
click.

Thanks



James B. wrote:
> Ste H. wrote:
>> no-one? I've tried everything it seems and dosnt seem to be doing
>> anything
>
> Sadly, this seems to be another one of those poorly-documented Rails
> scenarios.
>
> I managed to send a PDF attachment with a text E-mail message for a
> project that has since been put on hold (so I haven't run the code in
> two months, and don't recall just how well it worked).
>
> This is a method from my ActionMailer-derived class
>
>    def pdf_invoice mail_params, pdf
>      recipients  mail_params[ :to ]
>      cc          mail_params[ :cc ]
>      from        mail_params[ :user_email ]
>      subject     mail_params[ :subject ]
>
>      part :content_type => "text/plain",
>           :body => render_message( 'pdf_invoice.text.plain',
>                                     :note => mail_params[ :note ]  )
>
>
>      attachment :content_type => "application/pdf",
>         :filename => mail_params[ :base_filename ].to_s + '.pdf',
>         :body => pdf
>
>    end
>
>
>
>
>
> --
> James B.
>
> Judge a man by his questions, rather than his answers.
>   - Voltaire
This topic is locked and can not be replied to.