Try this one

 public static void sendAsAttachment(Context context, File file){

Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
emailIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL,new String[] { "
cta...@gmail.com" });
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "Note Taker
Image"); emailIntent.putExtra(Intent.EXTRA_TEXT, "Image Sent from
AndroidPhone");
emailIntent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(file));
emailIntent.setType("vnd.android.cursor.dir/email");
 try{
         ((Activity)
context).startActivity(Intent.createChooser(emailIntent, "Send file as
attachment"));
       }catch (Exception e) {
        Toast.makeText(context, "No application has been installed to
support this operation.", 250).show();
     }
  }

context - context of the Activity from where you are calling this method
file - the file which you want to send as attachment


---------- Forwarded message ----------
From: LaxmiRamGanesh <ganeshpa...@gmail.com>
Date: Wed, Nov 9, 2011 at 10:17 AM
Subject: [android-developers] attachment through mail
To: Android Developers <android-developers@googlegroups.com>




Hi,
i have issue on my application , coding sucessfully executed , but
file not attach in my email , its only shows filename , but not
image .

code:
Intent emailintent = new Intent(Intent.ACTION_SEND);


           emailintent.setType("image/jpg");

emailintent.putExtra(android.content.Intent.EXTRA_EMAIL,Uri.fromParts("mailto",
"cta...@gmail.com", null));

                       emailintent.putExtra(Intent.EXTRA_SUBJECT, "Note
Taker Image");
                       emailintent.putExtra(Intent.EXTRA_TEXT, "Image Sent
from Android
Phone");
                       emailintent.putExtra(Intent.EXTRA_STREAM,
Uri.parse("file://mnt/
sdcard/e-Diary/image7115332.jpg"));

                       //emailintent.putExtra(Intent.EXTRA_STREAM, );
                       startActivity(emailintent);


regards,
Ganez

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to