Skip to content Skip to sidebar Skip to footer

Sending An Email With An Attachment From An Application

I'm creating an app that has an 'export' feature which converts the user's data into a CSV file, and allows the user to send it as an attachment to somebody (presumably themselves)

Solution 1:

i've done for send any file from SD card with mail attachment..

Intent sendEmail= new Intent(Intent.ACTION_SEND);
       sendEmail.setType("rar/image");
       sendEmail.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(new        
         File("/mnt/sdcard/download/abc.rar")));
         startActivity(Intent.createChooser(sendEmail, "Email:"));

Solution 2:

need the correct path for your file, if on SD card then...

sendIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse 
("file://"+Environment.getExternalStorageDirectory()+getString(R.string.csv_title)"));

Look here for addition information on setting the appropriate file path

http://developer.android.com/guide/topics/data/data-storage.html#filesExternal

Solution 3:

GMail app accepts file:// Uris only if they are on the sdcard... and on an android 1.6 device I had even an issue with it accepting only file://sdcard/* Uris whereas the real external storage of this specific device is on another path.

Anyway, I have a real better behavior with attachments since I provide them through a ContentProvider.

Post a Comment for "Sending An Email With An Attachment From An Application"