Embed A Image In Email Body From Saving And Picking In Sdcard In Android
I'm trying to embed a inline image in email body by saving in sdcard and then picking from that place but image is not being shown and just 'obj' is shown there.Kindly help me out,
Solution 1:
Try this to save the file:
try {
File myFile = new File("/sdcard/mysdfile.jpg");
myFile.createNewFile();
FileOutputStream fOut = new FileOutputStream(myFile);
OutputStreamWriter myOutWriter =
new OutputStreamWriter(fOut);
myOutWriter.append(txtData.getText());
myOutWriter.close();
fOut.close();
Toast.makeText(getBaseContext(),
"Done writing SD 'mysdfile.txt'",
Toast.LENGTH_SHORT).show();
} catch (Exception e) {
Toast.makeText(getBaseContext(), e.getMessage(),
Toast.LENGTH_SHORT).show();
}
Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
emailIntent.setType("application/image");
emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, new String[]{strEmail});
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT,"Test Subject");
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, "From My App");
emailIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse("file:///mnt/sdcard/mysdfile.jpg"));
startActivity(Intent.createChooser(emailIntent, "Send mail..."));
And make sure you add the correct permission in your manifest:
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE">
Post a Comment for "Embed A Image In Email Body From Saving And Picking In Sdcard In Android"