I am Using Following code to attach Image and Text in email .
private void friends_email_share() {
// send Email to Bob to notify site
Log.i("Send email", "");
String mail_body = "<!DOCTYPE html><html><body>\n" +
" <p>Hi,</p>\n" +
" <p>Check out <b>Some dummy Text</p>\n" +
" <p>Some dummy Text Some dummy Text Some dummy Text.</p>\n" +
" <p>Some dummy Text Some dummy TextSome dummy Text Some dummy Text</p>\n" +
" <p>Some dummy TextSome dummy TextSome dummy Text</p>\n" +
"</body></html>";
String[] TO = {};
String[] CC = {};
Intent emailIntent = new Intent(Intent.ACTION_SEND);
emailIntent.setData(Uri.parse("mailto:"));
emailIntent.setType("text/html");
emailIntent.putExtra(Intent.EXTRA_EMAIL, TO);
emailIntent.putExtra(Intent.EXTRA_CC, CC);
emailIntent.putExtra(Intent.EXTRA_SUBJECT, "Bob Halstead's Coral Sea Fish Guide");
emailIntent.putExtra(Intent.EXTRA_TEXT, "" + "\n" + Html.fromHtml(mail_body));
String image_path = "file:///assets/all_images/" + species_name + ".jpg";
emailIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse(image_path));
try {
startActivity(Intent.createChooser(emailIntent, "Send mail..."));
Log.i("-->", "Finished sending email...");
} catch (android.content.ActivityNotFoundException ex) {
Toast.makeText(getApplicationContext(), "There is no email client installed.", Toast.LENGTH_SHORT).show();
}
}
I am able to attach Text but not able to attach image from internal storage from assets Folder .How do I attach an Image From from assets folder for sending mail using Gmail Intent with Intent.EXTRA_STREAM?...any kind of help would be appreciated ....thank you
Aucun commentaire:
Enregistrer un commentaire