Issue
I am sending email using intent but the subject and message body is not being set.
Intent sendMail = new Intent(Intent.ACTION_SEND);
sendMail.setType("*/*");
sendMail.setType("message/html");
sendMail.setPackage("com.google.android.gm");
sendMail.putExtra(Intent.EXTRA_EMAIL , email);
sendMail.putExtra(Intent.EXTRA_SUBJECT , subject);
sendMail.putExtra(Intent.EXTRA_TEXT , message);
startActivity(Intent.createChooser(sendMail , "Choose an Email Client"));
Solution
I also faced this problem. Be clear that those string
values are not null. You could also use ACTION.SENDTO
. Use the below code; it worked for me.
Intent sendMail = new Intent(Intent.ACTION_SENDTO);
sendMail.setData(Uri.parse("mailto:"));
final Intent intent = new Intent(Intent.ACTION_SEND);
intent.putExtra(Intent.EXTRA_EMAIL, new String[]{email});
intent.putExtra(Intent.EXTRA_SUBJECT, subject);
intent.putExtra(Intent.EXTRA_TEXT, message);
intent.setSelector( sendMail );
startActivity(Intent.createChooser(intent, "Choose an Email Client"));
Answered By - Ganesh MB
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.