Send an image from url as a attachment email in android
<p>I have a problem that I want to send an email with Image attachment and image is on Url. I am not able to send that. Please suggest me for right result.</p>

<p>Thanks in advance.</p>

<p>Here is the code:</p>

<pre><code> btn_mail.setOnClickListener(new View.OnClickListener() {
            public void onClick(View arg0) {
                setImage(item.getImageUrl());
                if(item instanceof Product)
                {
                body = "&lt;html&gt;&lt;body&gt;Found this a great deal on &lt;a href=http://www.bizrate.com&gt;@Bizrate&lt;/a&gt;&lt;a href="+item.getUrl()+"&gt; "+item.getTitle()+"&lt;/a&gt;&lt;br&gt;&lt;br&gt;&lt;img src="+item.getImageUrl(100)+"&gt;&lt;/body&gt;&lt;/html&gt;";
                }else
                {
                    Offer offer = (Offer)item;
                    body = "&lt;html&gt;&lt;body&gt;Found this a great deal on &lt;a href=http://www.bizrate.com&gt;@Bizrate&lt;/a&gt;&lt;a href="+item.getUrl()+"&gt; "+item.getTitle()+"&lt;/a&gt;&lt;br&gt;&lt;br&gt;&lt;img src="+item.getImageUrl(100)+"&gt;&lt;/body&gt;&lt;/html&gt;";
                }
                Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
                emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, item.getTitle());
                /*emailIntent.putExtra(android.content.Intent.EXTRA_TEXT,
                        "Title: " + item.getTitle() + "\n" +
                                "Description: " + item.getDescription() + "\n" + "\n" +
                                "Max Price: " + max_price + "\n" +
                                "Min Price: " + min_price);*/
                emailIntent.putExtra(android.content.Intent.EXTRA_TEXT,Html.fromHtml(body));
                //emailIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse("android.resource://com.shopzilla.android.common/" + R.drawable.barcode));
                //emailIntent.putExtra(Intent.EXTRA_STREAM, imageBitmap);
                emailIntent.setType("message/rfc822");
                context.startActivity(Intent.createChooser(emailIntent, "Send mail..."));
            }
        });


  private void setImage(String string) {
        try {
            URL url = new URL(string);
            imageBitmap = BitmapFactory.decodeStream(url.openConnection().getInputStream());

        } catch (MalformedURLException e) {

            e.printStackTrace();
        } catch (IOException e) {

            e.printStackTrace();
        }
    }
</code></pre>
