1

I want to send an email from my android application which have HTML content and also an image as attachment.My searching results revealed that it is not possible to send an image using tag of HTML.How can i achieve this?.ie, I want content in HTML(These are some URLs) and send an image as attachment.

Thanks in Advance

Asha Soman
  • 37
  • 1
  • 5
  • 2
    Have you [done any research](http://stackoverflow.com/questions/2007540/how-to-send-html-email)? – Cat Aug 13 '12 at 05:23

2 Answers2

2
String path = Images.Media.insertImage(getContentResolver(), bmp,"title", null);
Uri screenshotUri = Uri.parse(path);
Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
emailIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
emailIntent
        .putExtra(android.content.Intent.EXTRA_EMAIL, emailAddresses);
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, subject);
emailIntent.putExtra(Intent.EXTRA_STREAM, screenshotUri);
emailIntent.setType("image/png");
startActivity(Intent.createChooser(emailIntent, "Send email using"));

Its usefull to Send mail

ckpatel
  • 1,926
  • 4
  • 18
  • 34
2

for attaching images to mail do this

use Intent.ACTION_SEND to attach image from device to email like this

 File F = new File("/sdcardpath/imagename.png");
 Uri U = Uri.fromFile(F);
 Intent i = new Intent(Intent.ACTION_SEND);
 i.setType("image/png");
 i.putExtra(Intent.EXTRA_STREAM, U);
 startActivity(Intent.createChooser(i,"Email:"));

& for sending html content to email body do this

final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
emailIntent.setType("text/html");
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, subject);
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, Html.fromHtml(body));
startActivity(Intent.createChooser(emailIntent, "Email:"));
Community
  • 1
  • 1
Aamirkhan
  • 7,031
  • 11
  • 48
  • 75