简体   繁体   中英

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>"),
                         "android.tech1q2@gmail.com", et_mail.getText().toString().trim());
} catch (Exception e) {
    Log.e("SendMail", e.getMessage(), e);
}

//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..."));   

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM