Monday, 7 January 2013

Send Email With Attachment in Android (*** Working***)



Hello Friends,

send email from android device with attachment using intent here is the code for that

This code is perfectly working for me to send email with  image attachment

****+++++++++++++++++++++++++++++++++++++++++++*****


              Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
              emailIntent.setType("jpeg/image");
              emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL,
                           new String[] { "" });
              emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "subject");
              Date cal = Calendar.getInstance().getTime();
              emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, "body");

              Uri uri = Uri.fromFile(new File(Environment
                           .getExternalStorageDirectory(), "/sunil.jpg"));

              emailIntent.putExtra(Intent.EXTRA_STREAM, uri);
              emailIntent.setType("text/plain");

              startActivity(Intent.createChooser(emailIntent, "Send mail..."));

4 comments:

  1. This comment has been removed by the author.

    ReplyDelete
  2. Hi sunil i tried with your example but while sending an image it showing error on device that couldn't attach error

    ReplyDelete
  3. how to attach multiple files ?

    ReplyDelete

Call web services easily

get source code from here, Download