如何添加在电子邮件正文中的图像文中、图像、电子邮件

2023-09-11 12:38:22 作者:汨('Ω`。)瀜囮孒

我要添加图像的电子邮件正文。 我不想图像附加到电子邮件,但在邮件主体添加一个图像。

I want to add an image in email body. I don't want to attach an image to the email, but add an image in the email body.

如何做到这一点?

我用这个。

"<img src=\"data:image/png;base64,"+convertFileTOByteEncrypt()+"\">"

  "<img src=\"https://m.xsw88.com/allimgs/daicuo/20230911/4145.png.jpg\">"

然后图像显示是这样的。

Then image is displayed like this.

推荐答案

不幸的是,它不可能与意图做到这一点。

Unfortunately, it's not possible to do this with Intents.

为什么例如粗体文本显示在EditText上,而不是一个图像的原因是 StyleSplan 正在实施 Parcelable 而的 ImageSpan 没有。因此,当Intent.EXTRA_TEXT检索在新的活动的ImageSpan将无法unparcel并为此不追加到的EditText样式的一部分。

The reason why for example bold text is displayed in the EditText and not an Image is that StyleSplan is implementing Parcelable whereas ImageSpan does not. So when the Intent.EXTRA_TEXT is retrieved in the new Activity the ImageSpan will fail to unparcel and therefor not be part of the style appended to the EditText.

使用其他方法,你不传递数据的意图是不幸的是没有可能在这里,你是不是在接收活动的控制。

Using other methods where you don't pass the data with the Intent is unfortunately not possible here as you're not in control of the receiving Activity.