react-native-mail
react-native-mail copied to clipboard
Can not send image within body
I want to send email with image in body, as the library only support the simple translation for plain text, so update the code as below(The path is starting with /data/user/0/com.myapp/cache/image.jpg):
if (options.hasKey("body") && !options.isNull("body")) { String body = options.getString("body"); if (options.hasKey("isHTML") && options.getBoolean("isHTML")) { //i.putExtra(Intent.EXTRA_TEXT, Html.fromHtml(body)); i.putExtra(Intent.EXTRA_TEXT, Html.fromHtml(body,imageGetter, null)); } else { i.putExtra(Intent.EXTRA_TEXT, body); } }
And implementated the imageGetter as below:
final Html.ImageGetter imageGetter = new Html.ImageGetter() { @Override public Drawable getDrawable(String source) { Drawable drawable=null; drawable=Drawable.createFromPath(source); drawable.setBounds(0, 0, drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight()); return drawable; } }; But when open the mail client(Gmail in Android), the image does not show. Who can help on this? Thank you!