【问题标题】:how to send E-mail html content with images in mail body using android如何使用android在邮件正文中发送带有图像的电子邮件html内容
【发布时间】:2012-12-29 05:55:02
【问题描述】:

如何使用 android 在邮件正文中发送带有图像的电子邮件 html 内容

我的代码:

 final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND_MULTIPLE);
 emailIntent.setType("text/html");
 emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL,"to");
 emailIntent.putExtra(android.content.Intent.EXTRA_CC,"cc");
 emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT,"subject");
 emailIntent.putExtra(android.content.Intent.EXTRA_TEXT,Html.fromHtml(body));

this.startActivity(Intent.createChooser(emailIntent, "Choose your email program"));

但邮件正文不显示某些 html 包含和图像。

请帮帮我。

提前谢谢。

【问题讨论】:

  • 您是否在<img> 标签中发送图像?你能发布一些你正在发送的body 内容的sn-p。
  • 我在获取 json 数据时的身体内容
  • 在此处发布您的身体 json 数据
  • ......
  • 但邮件正文显示   濒危逃亡者:SASY ARULONG (HI)12/29/2012 12:00:00 PM 
  • pro.wrapmail.com/wraps/custom/images\user\6903_1_350.jpg" border="0" usemap="#top_map"/>

标签: android


【解决方案1】:

试试这个:

emailIntent.putExtra(android.content.Intent.EXTRA_TEXT,Html.fromHtml(new StringBuilder()
           .append(body).toString()));

代替:

emailIntent.putExtra(android.content.Intent.EXTRA_TEXT,Html.fromHtml(body));

编辑:

这是我的测试,它运行良好。

       String body = "<html><body><h1>this is h1</h1><b>wel come to html formet</b></body></html>";

       final Intent shareIntent = new Intent(Intent.ACTION_SENDTO, Uri.parse("mailto:"));
       shareIntent.putExtra(Intent.EXTRA_SUBJECT, "The Subject");
       shareIntent.putExtra(
       Intent.EXTRA_TEXT,
       Html.fromHtml(new StringBuilder()
           .append(body).toString())
       );
       startActivity(shareIntent);

谢谢。

【讨论】:

  • 我尝试像

    这是 h1

    欢迎来到 html 格式 html> 但得到我的 json 数据它不显示。
  • 感谢 pratik,我尝试使用此代码完成工作,但我添加了不显示的图像。
  • String body = "

    这是h1

    mindinventory.com/images/logo.gif'/></body></…>";最终意图 shareIntent = new Intent(Intent.ACTION_SENDTO, Uri.parse("mailto:")); shareIntent.putExtra(Intent.EXTRA_SUBJECT, "主题"); shareIntent.putExtra(Intent.EXTRA_TEXT,Html.fromHtml(new StringBuilder().append(body).toString())); startActivity(shareIntent);
  • @kailash 引用此线程。 [stackoverflow.com/a/6476890/556975] .Android 发送带有电子邮件正文的图像是一个未解决的问题。
  • 感谢 pratik 使用 inten not posible 但其他方式发送图像然后给我例子.....谢谢
猜你喜欢
  • 1970-01-01
  • 2019-01-20
  • 2014-07-13
  • 1970-01-01
  • 1970-01-01
  • 2018-04-29
  • 1970-01-01
  • 1970-01-01
  • 2014-01-29
相关资源
最近更新 更多