我想通过我的应用程序发送一封HTML格式的电子邮件,
但发送电子邮件时不支持所有标记的样式。
这是我的Java代码:
Intent emailIntent = new Intent(android.content.Intent.ACTION_SENDTO, Uri.fromParts("mailto", "", null));
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "Look What I Found!");
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT,
Html.fromHtml(mMessage)
);
startActivity(emailIntent);`
这是我的HTML,我想发送的是:
"<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Document</title> </head> <body> <center> <table style="width: 600px; margin:0 auto" cellpadding="0" cellspacing="0"> <tr> <td> <table> <tr> <td> <img src="https://www.twinspires.com/sites/twinspires.com/files/header-600x123.jpg" alt="Churchill Downs" style="display: block;width: 600px;height: 123px;"> </td> </tr> </table> <table style="padding:40px 0px;"> <tr> <td style="width: 50px;"> </td> <td> <p style="font-family: 'Open Sans', Helvetica, Arial, sans-serf;text-align: justify; font-style: 14px;">View this shared article from the Churchill Downs Incorporated Magazine $title. Download the official lifestyle app of Churchill Downs – "Club 1875" to access the elegant world of Thoroughbred racing and the Kentucky Derby. Stay up to date on fashion, food, celebrities and some of the most recognizable names in the industry. Club 1875 is your behind the scenes guide to the most exciting two minutes in sports – whether you’re at the track or far away! </p> </td> <td style="width: 50px;"> </td> </tr> </table> <center> <table> <tr> <td> <img src="https://www.twinspires.com/sites/twinspires.com/files/logo-235x98-02.jpg" alt="" style="display: block; width: 235px; height: 98px;" alt="CLUB 1875"> </td> </tr> </table> </center> <center> <table> <tr> <td> <a href="https://itunes.apple.com/us/app/club-1875/id1171549047?mt=8" target="_blank"><img src="https://www.twinspires.com/sites/twinspires.com/files/icon-148x40-02.jpg" alt="Download Here" style="display: block;width:148px;height: 40px; "></a> </td> </tr> </table> </center> <center> <table style="padding-top: 40px;"> <tr> <td> <img src="https://www.twinspires.com/sites/twinspires.com/files/footer-558x278.jpg" style="display: block;width: 558px;height: 278px;" a"
下面是我发送电子邮件时的输出:
最佳答案
试试这个。
String mailId="yourmail@gmail.com";
Intent emailIntent = new Intent(Intent.ACTION_SENDTO, Uri.fromParts("mailto",mailId, null));
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "Subject text here");
// you can use simple text like this
// emailIntent.putExtra(android.content.Intent.EXTRA_TEXT,"Body text here");
// or get fancy with HTML like this
emailIntent.putExtra(
Intent.EXTRA_TEXT,
Html.fromHtml(new StringBuilder()
.append("<p><b>Some Content</b></p>")
.append("<a>http://www.google.com</a>")
.append("<small><p>More content</p></small>")
.toString())
);
startActivity(Intent.createChooser(emailIntent, "Send email..."));
关于android - 如何在android中以html格式的电子邮件发送图像?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/43796721/