I’m developing an Android application where the user must be able to send a file stored on the SD Card to a specific e-mail address. By using Android’s Intent class this is very easy. The following code snippet will bring up an e-mail application choose dialog.
String filename = "file://" + Environment.getExternalStorageDirectory() + "/file.txt"; String email[] = { "foo@bar.com" }; Intent sendIntent = new Intent(Intent.ACTION_SEND); sendIntent.putExtra(Intent.EXTRA_SUBJECT, "My file"); sendIntent.putExtra(Intent.EXTRA_EMAIL, email); sendIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse(filename)); sendIntent.setType("text/plain"); startActivity(Intent.createChooser(sendIntent, "EMail file"));
