Rails, emails and html code - ruby-on-rails-3

When my rails app sends an email to a gmail account with the body as html code dynamically generated, in the email the html code is displayed and the html is not rendered.
my html is dynamically generated something like this:
html = "<html><table> ...... </table></html>"
and the email displays all of that html code
Do i need to add any specific headers or anything?

I would suggest taking a look at the Action Mailer Rails Guide. Sounds like you're only using the mailer part of Action Mailer. You should avoid hand crafting HTML into a variable like that, it's not the Rails-way.
I'd also suggest taking a look at Ryan Bate's screencast on Sending HTML Email.

Try
html.html_safe
to render the text of html as HTML type instead of plain text, or your tags will be html-escaped...

Related

Visualforce page rendered as pdf can be sent for Esign using Docusign

Can we send Visualforce page rendered as pdf for Esignature using Docusign.
Cannot use template function provided by DocuSign as a number of components are dynamic which can't be done using Docusign template.
Any ideas?
You want a VisualForce page turned into a PDF and then sent to DocuSign for signature?
The first part (turning a VisualForce page into a PDF) is the hard part. You need to accomplish that.
The usual technique is to have your application create a dynamic document on the fly, then send it to DocuSign. You can create PDFs dynamically using a software library.
But it is often easier to create an HTML document. If you send an HTML document to DocuSign, then it must use inline CSS styling (not an external style sheet) and must also include inline graphics via the data: URL type

Styling the html with style tags in Amazon SES templates

I am trying to style the content of my email html template on Amazon SES, by including a style tag. But it is not rendered when I receive the email.
Please let me know how can I apply styles to my email and also include images in my email using Amazon ses.
Thanks in advance
Try this,
set the below part to Html field.
<html><head><style> .cl{ color:blue;background-color:yellow}</style></head><body><button class='cl'>hello</button></body></html>
When you send this you will get the button with blue text and background with yellow as shown below
Hope this helps!!
Note: don't miss the head tag

Post html content to an activity with Google + Domains API

I'm triying to post HTML content to an activity with the new google + domains API with no success.
Activity activity = new Activity()
.setObject(new Activity.PlusObject().setContent("First line<br><b>second line</b>"))
.setAccess(acl);
Acording to the documentation with setConent you can specify "The HTML-formatted content, which is suitable for display." but when i try to post some html its get displayed as plain text.
I need to create an activity with some linebreaks and bold text. How can i achieve that?
Thanks in advance.
the content (HTML) field is only meant for output, you are not allowed to write in HTML. You should be writing in plain text (as you do in the browser), newlines are respected with normal line breaks (\n)
This field is useful to display formatted posts that contain links etc..

Xcode - Add hyperlink to email

In some apps you can email straight from the app. I have seen Flipboard, you can email an article to a friend and inside the email is hyperlinked text like this:
Sent via Flipboard
So it directs you to the page with a click of the text. How can I do this? I do not want to add the link as part of the message body as it is very messy and ugly... I would prefer this clickable text way.
Thanks!
The MFMailComposeViewController has a method called
setMessageBody:isHTML:.
Here the important thing is isHTML.
Doing a link in HTML is quite simple : <a href=myURL>LinkName</a>.

Rails 3 rendering iframe with raw()

So I am storing the whole embed code from youtube into my database and then outputting it like this.
<%= raw(people.video) %>
which outputs the general iframe tag copied from youtube:
<iframe src="foo" width=400 height=380></iframe>
the problem is that it actually displays that tag instead of embedding the video into the page itself. I can get around this just by storing the src in the database.... but this is part of a mini cms system and the site admins would find it much easier just to copy and past the embed code from youtube. Is there someway I can specify for the iframe to actually render instead of just spitting out the html on the page?
You can use the raw method to render the HTML of a string, are you storing it that way? You can also try the RedCloth gem - I was able to get this working like so:
<%= raw RedCloth.new(#page_content.content).to_html %>
Which allowed for my custom CMS to use the Textile markup
http://en.wikipedia.org/wiki/Textile_%28markup_language%29
I'm not 100% on what you're seeing, since raw should render HTML, but you might also try to include the embed tag using a JavaScript.write, since there are some issues related to Flash objects embedded in HTML vs JavaScript.
Let me know if this doesn't work, and if so, can you provide screenshots or copy what you're seeing on the page?