From an Android app, I'm trying to send an email with an HTML body with img embedded. From what I read, the following should work. The letter was received with an HTML bold tag working correctly, etc., However, img is replaced with [OBJ]. My journal tells me that I really get Drawable with the correct sizes, etc., Therefore, it seems that the local email client does not understand the image in Spannable. Is there any trick, for example, images must come from the URI "content:"? thanks!
Intent i = new Intent(Intent.ACTION_SEND); i.putExtra(Intent.EXTRA_SUBJECT, "Sample subject"); i.setType("text/html"); Spanned html = Html.fromHtml( "<html><body>h<b>ell</b>o<img src='http://www.pp.rhul.ac.uk/twiki/pub/TWiki/GnuPlotPlugin/RosenbrockFunctionSample.png'>world</body></html>", new ImageGetter() { public Drawable getDrawable(String url) { InputStream s = (InputStream) (new URL(url)).getContent(); Drawable d = Drawable.createFromStream(s, null); LogUtil.debug(this, "Got image: " + d.getClass() + ", " + d.getIntrinsicWidth() + "x" + d.getIntrinsicHeight()); d.setBounds(0, 0, d.getIntrinsicWidth(), d.getIntrinsicHeight()); return d; } ), null ); i.putExtra(Intent.EXTRA_TEXT, html); startActivity(Intent.createChooser(i, "Send email"));
nickk source share