Reputation: 31
I am developing an android application that can send email. This following code lets me send email from my default gmail app on android device. I was wondering what the classes i should set so that i can send email from default android mail application?
Intent sendIntent = new Intent(Intent.ACTION_VIEW);
sendIntent.setClassName("com.google.android.gm","com.google.android.gm.ComposeActivityGmail");
sendIntent.putExtra(Intent.EXTRA_EMAIL, new String[] { "[email protected]" });
sendIntent.setData(Uri.parse("[email protected]"));
sendIntent.putExtra(Intent.EXTRA_SUBJECT, "enter subject");
sendIntent.setType("plain/text");
sendIntent.putExtra(Intent.EXTRA_TEXT, "Insert text");
startActivity(sendIntent);
Upvotes: 3
Views: 6502
Reputation: 20643
You don't have to. I am using following to send an email with default mail service.
Uri uri = Uri.parse("mailto:[email protected]");
Intent myActivity2 = new Intent(Intent.ACTION_SENDTO, uri);
myActivity2.putExtra(Intent.EXTRA_SUBJECT,
"Customer comments/questions");
startActivity(myActivity2);
Upvotes: 11