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 {
FilemyFile=newFile("/sdcard/mysdfile.jpg");
myFile.createNewFile();
FileOutputStreamfOut=newFileOutputStream(myFile);
OutputStreamWritermyOutWriter=newOutputStreamWriter(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();
}
IntentemailIntent=newIntent(android.content.Intent.ACTION_SEND);
emailIntent.setType("application/image");
emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, newString[]{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-permissionandroid:name="android.permission.WRITE_EXTERNAL_STORAGE">
Post a Comment for "Embed A Image In Email Body From Saving And Picking In Sdcard In Android"