Forum: Ruby on Rails Html Email Problem

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.
71c1fa9c3722207bf47786b5b277bd6f?d=identicon&s=25 Keyon (Guest)
on 2006-05-17 08:33
Dear Rubyians,

I am facing problems to send Html Email scnce one month.

I changed  the  content type is text/html and charecter set  "utf-8"

I worte the html code in the confirm.heml in the action mailer folder.

but mail is going  with html code


Exapmle: <html  border="2"> <tr><td></td></tr></html> code in the
confirm .html

In the mail i got total code same format  what is the wrong


I am also sending the total code in the controller also.

order= Order.find_session(params['ses_value'])
order = Order.find_by_name("admin")
email = OrderMailer.create_confirm(order)
email.set_content_type("text/html")
render(:text => "<pre>" + email.encoded + "</pre>")
OrderMailer.deliver_confirm(order)

I also saw the  message i.e content type has changed to text/html

What is the problm I searching for solution since one month.

Please give me the references.

With Regards,
-Keyon
2ac135257f41acf16e8b2f2a2fa4ee81?d=identicon&s=25 Santhosh (Guest)
on 2006-05-17 09:09
Keyon wrote:
> Dear Rubyians,
>
> I am facing problems to send Html Email scnce one month.
>
> I changed  the  content type is text/html and charecter set  "utf-8"
>
> I worte the html code in the confirm.heml in the action mailer folder.
>
> but mail is going  with html code
>
>
> Exapmle: <html  border="2"> <tr><td></td></tr></html> code in the
> confirm .html
>
> In the mail i got total code same format  what is the wrong
>
>
> I am also sending the total code in the controller also.
>
> order= Order.find_session(params['ses_value'])
> order = Order.find_by_name("admin")
> email = OrderMailer.create_confirm(order)
> email.set_content_type("text/html")
> render(:text => "<pre>" + email.encoded + "</pre>")
> OrderMailer.deliver_confirm(order)
>
> I also saw the  message i.e content type has changed to text/html
>
> What is the problm I searching for solution since one month.
>
> Please give me the references.
>
> With Regards,
> -Keyon


Hello Keyon !
I am also fqacing same to send html!

Please help us we are waiting for your solution!

Thanks and Regards
Santhosh!
B26c571d17b3022ab1a98c1a223c32e6?d=identicon&s=25 David Thomson (Guest)
on 2006-05-17 09:49
(Received via mailing list)
You have to use a multipart email - Recipe 67 in the Rails Recipes
book covers this, and also more information in the ActionMailer docs:
http://api.rubyonrails.com/classes/ActionMailer/Base.html

Hope that helps,
David
2ac135257f41acf16e8b2f2a2fa4ee81?d=identicon&s=25 Santhosh (Guest)
on 2006-05-17 13:31
David Thomson wrote:
> You have to use a multipart email - Recipe 67 in the Rails Recipes
> book covers this, and also more information in the ActionMailer docs:
> http://api.rubyonrails.com/classes/ActionMailer/Base.html
>
> Hope that helps,
> David



Hi David!
I followed the same procedure  but i did not get the solution please

check this

--mimepart_446b08d593760_1f0300f69c183b
Content-Type: text/plain
Content-Transfer-Encoding: Quoted-printable
Content-Disposition: inline


<html><table border=3D2><tr><td>kkkkkkk</td></tr></table>

Thank you for placing the order from The WinIT JEWELS Stores.



--mimepart_446b08d593760_1f0300f69c183b
Content-Type: text/html; charset=utf-8
Content-Transfer-Encoding: Quoted-printable
Content-Disposition: inline


<html><table border=3D2><tr><td>kkkkkkk</td></tr></table>

Thank you for placing the order from The WinIT JEWELS Stores.



--mimepart_446b08d593760_1f0300f69c183b--

I got this type of out put what is the wrong please help me!
thanks and Regards,
-Keyon!
B26c571d17b3022ab1a98c1a223c32e6?d=identicon&s=25 David Thomson (Guest)
on 2006-05-17 15:34
(Received via mailing list)
It looks like the templates for each format aren't set up properly -
just to check the obvious, make sure that your plain.rhtml is actually
just plain text and doesn't have any HTML tags. I haven't worked with
Action Mailer in the past, so I'm not sure how much more help I can
be.
0a3167a5d3fd3fbbc1ad7e5a15aca6e2?d=identicon&s=25 Keypon (Guest)
on 2006-05-17 16:11
David Thomson wrote:
> It looks like the templates for each format aren't set up properly -
> just to check the obvious, make sure that your plain.rhtml is actually
> just plain text and doesn't have any HTML tags. I haven't worked with
> Action Mailer in the past, so I'm not sure how much more help I can
> be.

Please give the right path  to find the solution

Thanks and Regards,
-Keyon
Edca4a485b59dadb14dbc06704def3f2?d=identicon&s=25 Miroslav Zahorak (Guest)
on 2006-07-06 17:26
(Received via mailing list)
> Content-Type: text/html; charset=utf-8
> Content-Transfer-Encoding: Quoted-printable
> Content-Disposition: inline
>
> <html><table border=3D2><tr><td>kkkkkkk</td></tr></table>
>
> Thank you for placing the order from The WinIT JEWELS Stores.
>
> --mimepart_446b08d593760_1f0300f69c183b--


Hi guys,
I have the same problem, HTML part ofthe message is in emial twice,
It looks ok in Apple Mail, but in
MS Outlook it shows just as html code..

Anybody any idea?
Miro
Ef3aa7f7e577ea8cd620462724ddf73b?d=identicon&s=25 Rob Biedenharn (Guest)
on 2006-07-06 19:50
(Received via mailing list)
On Jul 6, 2006, at 11:13 AM, Miroslav Zahorak wrote:

>> Content-Type: text/html; charset=utf-8
> Hi guys,
> I have the same problem, HTML part ofthe message is in emial twice,
> It looks ok in Apple Mail, but in
> MS Outlook it shows just as html code..
>
> Anybody any idea?
> Miro

Well, you don't give your code, but here's an example that will
generate a multi-part email.  Note that if your message template is
named "multipart_alternative.rhtml", then the content_type picks it
up as the first part and then two more get added.

If this is your problem, change the name in the render_message and on
the actual file and try it again.

-Rob

Rob Biedenharn		http://agileconsultingllc.com
Rob@AgileConsultingLLC.com

### app/models/my_email_notifier.rb
class MyEmailNotifier < ActionMailer::Base

   def multipart_alternative(recipient, extra_stuff, sent_at = Time.now)
     subject      'Cool Multipart Email'
     recipients    recipient
     from         'me@localhost'
     sent_on       sent_at
     content_type 'multipart/alternative'

     part :content_type => "text/plain",
      :body => render_message("multipart_alternative_plain", :stuff
=> extra_stuff)
     part :content_type => "text/html",
      :body => render_message("multipart_alternative_html", :stuff =>
extra_stuff)
   end
end


### app/views/my_email_notifier/multipart_alternative_plain.rhtml
This is the cool part
<%= @stuff %>

### app/views/my_email_notifier/multipart_alternative_plain.rhtml
<html>
<body>
<p>This is the cool part</p>
<p><strong><%=h @stuff %></strong></p>
</body>
</html>

###
Edca4a485b59dadb14dbc06704def3f2?d=identicon&s=25 Miroslav Zahorak (Guest)
on 2006-07-07 10:01
(Received via mailing list)
Rob Biedenharn <Rob@...> writes:

> Well, you don't give your code, but here's an example that will
> generate a multi-part email.  Note that if your message template is
> named "multipart_alternative.rhtml", then the content_type picks it
> up as the first part and then two more get added.
>
> If this is your problem, change the name in the render_message and on
> the actual file and try it again.
>
> -Rob

I realized exactly what you said just few hours after my post,
i renamed my html view file to action_name_html.rhtml and all works
as expected.
What happened was that AM picked up default html template
because its name was the same as name of action and then also
it was added as part of message... through:
":body => render_message("reservation_email_plain""

Thanks
Miro
This topic is locked and can not be replied to.