我试图用HTML格式发送包含一些格式化文本的电子邮件。 此文本有一个指向我的图像的链接,并且不会显示此图像,就像链接被展开一样。我测试了图像的链接,它工作正常。
这是代码:
textoEmail = Html.fromHtml("<img src='https:link to my image'></br></br>Text<br/>Download it: http://Link to my app");
btEmail.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
emailIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
emailIntent.setType("vnd.android.cursor.item/email");
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "Carrorama - Recomendação de aplicativo");
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, textoEmail);
try {
startActivity(emailIntent);
} catch (ActivityNotFoundException e) {
}
}
});
答案 0 :(得分:0)
试试此代码
String body="<!DOCTYPE html><html><body><a href=\"http://www.w3schools.com\" target=\"_blank\">Visit W3Schools.com!</a>" +
"<p>If you set the target attribute to \"_blank\", the link will open in a new browser window/tab.</p></body></html>";
final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
emailIntent.setType("text/html");
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, subject);
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, Html.fromHtml(body));
startActivity(Intent.createChooser(emailIntent, "Email:"));