1

我想在 Android 的电子邮件正文中添加图像。

我使用 INTENT.EXTRA_STREAM 附加了一张图片,但这不是我想要的。我想要它在电子邮件正文中。
我尝试了以下代码,但它不起作用,谁能给我另一种方法来完成任务?

      String html="<p>This is a html-formatted string with <b>bold</b> and <i>italic</i> text</p><img src=\"screenshot.jpg\"";
                i.putExtra(Intent.EXTRA_TEXT,Html.fromHtml(html,
                        new ImageGetter() {

                    public Drawable getDrawable(String source) {
                        // TODO Auto-generated method stub
                         String base = Environment.getExternalStorageDirectory().getAbsolutePath().toString();

                         String imagePath = "/sdcard/screenshot.jpg";//"file://"+ base+"/"+ source;
                            Drawable bmp = Drawable.createFromPath(imagePath);
                           // bmp.setBounds(0, 0, bmp.getIntrinsicWidth(), bmp.getIntrinsicHeight());

                            return bmp;
                    }
                },null));
4

1 回答 1

0

You can do that using JavaMail Api

Here is sample code to do that,

于 2012-05-04T12:40:39.903 回答