On Jan 21, 2011, at 2:22 PM, Jim Burgess wrote:
> Hi,
>
> I'm trying to use ActionMailer to send an image as an attachment to an
> email. Here's my code:
>
> class ContactMailer < ActionMailer::Base
> def message(sent_at = Time.now)
> from '[email protected]'
> recipients '[email protected]'
> subject 'New message'
> sent_on sent_at
> body {}
> attachment :content_type => "image/jpeg", :body =>
> File.read("public/images/rails.png")
Content type is JPEG. File you're reading is PNG.
> end
> end
>
> This works, in so far as the email is delivered okay (obviously with
> different addresses), but the image attached to the email seems to be
> corrupted.
>
> It doesn't display in my mail client and when I download it and try to
> open it with a suitable program I get the message that the file is
> either too large or corrupted.
>
> I tried replacing the image with a pdf as follows:
> attachment :content_type => "application/pdf", :body =>
> File.read("public/images/test.pdf")
> and this works fine.
>
> Can anybody give me a clue as to what I'm doing wrong?
>
> Thanks in advance.
>
> --
> Posted via http://www.ruby-forum.com/.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ruby on Rails: Talk" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/rubyonrails-talk?hl=en.
>
--
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.