Created
June 26, 2011 19:11
-
-
Save kodeshpa/1047873 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Method to attach and send files from android application | |
*/ | |
private void emailFiles(String filePath) { | |
Intent sendIntent = new Intent(Intent.ACTION_SEND); | |
sendIntent.setType("text/plain"); | |
sendIntent.putExtra(Intent.EXTRA_TEXT, report); | |
if(!TextUtils.isEmpty(filePath)){ | |
File fileIn = new File(filePath); | |
Uri u = Uri.fromFile(fileIn); | |
sendIntent.putExtra(Intent.EXTRA_STREAM, u); | |
} | |
String currentDateTimeString = DateFormat.getDateInstance().format(new Date()); | |
sendIntent.putExtra(Intent.EXTRA_SUBJECT, "MyEmail " + currentDateTimeString ); | |
try{ | |
startActivity(Intent.createChooser(sendIntent, "Select Destination")); | |
}catch (android.content.ActivityNotFoundException ex) { | |
Toast.makeText(YouActivityName.this, "There are no email clients installed.", Toast.LENGTH_SHORT).show(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment