【问题标题】:losing hyperlinks in the email android在电子邮件android中丢失超链接
【发布时间】:2014-01-15 15:21:02
【问题描述】:

我试过了

Intent mIntent = new Intent(Intent.ACTION_SEND);
mIntent.putExtra(Intent.EXTRA_SUBJECT, "this is test");
mIntent.setType("text/html");  
Uri myUri = Uri.parse("http://www.Google.com/");
mIntent.putExtra(android.content.Intent.EXTRA_TEXT,Html.fromHtml("<a href=\""+myUri+"\">Link</a>"));
            context.startActivity(android.content.Intent.createChooser(mIntent, "Email:"));

我也尝试过 setType("消息/rfc822");

一切都是徒劳的,我的电子邮件没有问题(工作正常)。但是我看不到超链接,在另一端收到的原始消息甚至没有超链接href下面显示的内容

*MIME-Version: 1.0
Received: by 10.49.25.98 with HTTP; Thu, 3 Jan 2013 08:42:55 -0800 (PST)
Received: by 10.49.25.98 with HTTP; Thu, 3 Jan 2013 08:42:55 -0800 (PST)
Date: Thu, 3 Jan 2013 11:42:55 -0500
Delivered-To: DELETED
Message-ID: DELETED
Subject: this is test
From: DELETED
To: DELETED
Content-Type: multipart/alternative; boundary=047d7bea41ce0280df04d2650e27
--047d7bea41ce0280df04d2650e27
Content-Type: text/plain; charset=ISO-8859-1
Link
--047d7bea41ce0280df04d2650e27
Content-Type: text/html; charset=ISO-8859-1
<p dir="ltr">Link</p>
--047d7bea41ce0280df04d2650e27--*

【问题讨论】:

  • 如果您使用的是ACTION_SEND,则不需要邮件客户端支持 HTML 邮件,或者保持不变。特别是,您将受到电子邮件客户端消息编辑器的编辑环境的限制。如果编辑器不支持 HTML,您的 HTML 可能会在发送电子邮件时被取消标记。
  • 在使用之前阅读 Html.fromHtml 文档(和返回类型)。问问自己,你希望它做什么?
  • 也许您是 GMail 4.2.1 中看起来非常丑陋的回归的受害者? stackoverflow.com/questions/13756200/…
  • 这是真的,但是有没有办法通过意图在电子邮件中发送超链接,或者就像不发送超链接一样?
  • 在 4.2.1 之前的 GMail 应用程序版本中,您可以按照您在此处显示的方式添加超链接,它们会按预期工作。

标签: android android-intent html-email


【解决方案1】:
Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, recipients);
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, subject);
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT,Html.fromHtml(emailtext.toString()));
emailIntent.setType("text/html");
startActivity(Intent.createChooser(emailIntent, "Send mail..."));

适用于设置为的电子邮件文本:

String emailtext = "<a href="+actionUrl+">"+shareTextContent+"</a>";

action url 可能类似于:

actionUrl = "www.google.com"

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-06-11
    • 1970-01-01
    • 2014-05-15
    • 2022-11-22
    • 2013-08-03
    • 2020-08-30
    相关资源
    最近更新 更多