如何在电子邮件正文中添加图像
我想在电子邮件正文中添加图像。 我不想在电子邮件中附加图像,而是在电子邮件正文中添加图像。
如何做到这一点?
我正在用这个。
"<img src=\"data:image/png;base64,"+convertFileTOByteEncrypt()+"\">"
或
"<img src=\"http://images.anandtech.com/doci/3982/HTCSurround-0134.jpg\">"
然后图像显示如下。
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.
How to do this?
I'm using this.
"<img src=\"data:image/png;base64,"+convertFileTOByteEncrypt()+"\">"
or
"<img src=\"http://images.anandtech.com/doci/3982/HTCSurround-0134.jpg\">"
Then image is displayed like this.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
不幸的是,用意图来做到这一点是不可能的。
例如,在 EditText 中显示粗体文本而不是图像的原因是 StyleSplan 正在实现 Parcelable 而 ImageSpan 没有。因此,当在新 Activity 中检索 Intent.EXTRA_TEXT 时,ImageSpan 将无法解包,因此不会成为附加到 EditText 的样式的一部分。
不幸的是,使用其他不通过 Intent 传递数据的方法在这里是不可能的,因为您无法控制接收活动。
Unfortunately, it's not possible to do this with Intents.
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.
这是相关问题。
看来您可以使用:
其中
uri
是文件路径URI
。Here is a related question.
It seems that you can use:
where
uri
is a file pathURI
.您必须创建一封包含 HTML 正文和嵌入图像的电子邮件: http://www.campaignmonitor.com/blog/post/1761/embedding-images-in-email/
要在 Android 中发送电子邮件,请按照以下食谱操作:如何在 Android 中发送电子邮件?
You have to create an email with HTML body and embedded image: http://www.campaignmonitor.com/blog/post/1761/embedding-images-in-email/
To send email in Android follow this recipe: How to send email in Android ?