繁体   English   中英

如何在android中以html格式的电子邮件发送图像?

[英]How to send image in html formatted email in android?

我想通过我的应用程序发送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..."));

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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