user3339689
user3339689

Reputation:

How format email body in grails?

I want to send email using my grails application. It is working fine but what i need is i want to format the email body with bold , italics , bullet lists , text colors etc. I tried using html markup like

      <strong> Hello </strong>  

for bold

 <br>

for line brake etc. But the received mail content shows the html code itself. How i can solve this? Thanks in advance.

sendMail {
                async true
                to toAddress
                subject "New cycle initiated"
                body "<p><span style='color:#ffffe0'><strong><span style='background-color:#ff0000'>Appraisal Initiated mail notification. This is a test mail</span></strong></span></p>"
                }

this is my code

Upvotes: 0

Views: 1347

Answers (2)

Carlos Alberto
Carlos Alberto

Reputation: 41

You can create a single GSP file and call it in sendMail as below.

File in 'grails-app/components/mail.gsp'

sendMail { async true
           to toAddress
           subject "blablabla"
           body(view:"/components/mail", model:[data:data])}

Upvotes: 1

doelleri
doelleri

Reputation: 19702

To send mail as HTML using the Grails mail plugin, you need to use the html parameter instead of body.

sendMail {
    async true
    to toAddress
    subject "New cycle initiated"
    html "<p><span style='color:#ffffe0'><strong><span style='background-color:#ff0000'>Appraisal Initiated mail notification. This is a test mail</span></strong></span></p>"
}

Upvotes: 3

Related Questions