Jignesh Ansodariya
Jignesh Ansodariya

Reputation: 12685

How to send mail in HTML format?

I want to send mail from my android application to given address. But new I am able send only plain text message. I want some text bold/underlines in different colors also. you can see my code below in which I used html form to bold/underline text but I got mail with normal(plain) text means no effect of what should I do for this. Thanks.

try {
GmailSender sender = new GmailSender("sender_email_id","password");
sender.sendMail("Thank you  state", ""+Html.fromHtml("<u>Jignesh</u><b>Jignesh</b>"),
                         "[email protected]", et_mail.getText().toString().trim());
} catch (Exception e) {
    Log.e("SendMail", e.getMessage(), e);
}

Upvotes: 1

Views: 1223

Answers (1)

Padma Kumar
Padma Kumar

Reputation: 20031

//Send an Url link to mail through aplication // using Html.fromHtml(mailBody)

String mailBody="Hello. I think you’d really enjoy this:"+
                "<a href='www.google.com'> Serach Engine   </a>"+//Serach Engine  +"<br/>"+

                "<br/> Name : <br/>"+
                "<br/> Ingredients"+"<br/>"+"<br/>";
                Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND); 
                emailIntent.setType("text/html"); 
                emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "Serach Engine"); 
                emailIntent.putExtra(android.content.Intent.EXTRA_TEXT,Html.fromHtml(mailBody));                        
                startActivity(Intent.createChooser(emailIntent, "Send mail..."));   

Upvotes: 1

Related Questions