Issue
When I try to send an email Intent no matter if I am using INTENT.ACTION_SEND or ACTION.SENDTO and use the stock Sony Xperia Active email client the subject and the recipients show up fine but the body is empty except for the standard comment pasted by the client. On my Samsung Galaxy Note 2 the same code works like charm.
if(mPrefs.getBoolean("alternative_email_client", false)){
Intent send = new Intent(Intent.ACTION_SENDTO);
String uriText = "mailto:" + Uri.encode(emailStrings[6]) +
"?subject=" + Uri.encode("The subject") +
"&body=" + Uri.encode(emailBody);
Uri uri = Uri.parse(uriText);
send.setData(uri);
startActivity(Intent.createChooser(send, "Email verschicken"));
} else {
Intent send = new Intent(Intent.ACTION_SEND);
send.putExtra(Intent.EXTRA_EMAIL, emailStrings[6]);
send.putExtra(Intent.EXTRA_SUBJECT, "The Subject");
send.putExtra(Intent.EXTRA_TEXT, emailBody);
startActivity(Intent.createChooser(send, "Email verschicken"));
}
Solution
To send an email with a body, use message/rfc822.
Intent sendIntent = new Intent(Intent.ACTION_SEND);
sendIntent.setType("message/rfc822");
sendIntent.putExtra(Intent.EXTRA_EMAIL, new String[] { "[email protected]", "[email protected]" });
sendIntent.putExtra(Intent.EXTRA_SUBJECT, "Subject of the email");
sendIntent.putExtra(Intent.EXTRA_TEXT, "Content of the email");
startActivity(sendIntent);
Hope this helps.
Answered By - Aswin Rajendiran
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.