How to add an image in email body

左心房为你撑大大i 提交于 2019-11-26 06:35:13

问题


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.

\"image\"


回答1:


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.




回答2:


Here is a related question.

It seems that you can use:

intent.putExtra(Intent.EXTRA_STREAM, uri);

where uri is a file path URI.




回答3:


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 ?



来源:https://stackoverflow.com/questions/5244472/how-to-add-an-image-in-email-body

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!