Reputation: 23
My code is this:
Intent i = new Intent(Intent.ACTION_SENDTO);
i.putExtra(Intent.EXTRA_EMAIL,"example @example. Com");
i.putExtra(Intent.EXTRA_SUBJECT,"Grannylaunch Support Needed:" + System.currentTimeMillis());
startActivity(i);
Toast.makeText(getApplicationContext(),"Emailing Support....", Toast.LENGTH_LONG);
My problem is the intent isnt starting an activity. What am I doing wrong and how do I fix it?
I have tried settting intent = Intent.ActionSend instead but doesnt work.
EDIT -
Intent i = new Intent(Intent.ACTION_SENDTO);
i.putExtra(Intent.EXTRA_EMAIL,"[email protected]");
i.putExtra(Intent.EXTRA_SUBJECT,"Grannylaunch Support Needed:" + System.currentTimeMillis());
i.putExtra(Intent.EXTRA_TEXT,"");
startActivity(i);
Toast.makeText(getApplicationContext(),"Emailing Support....", Toast.LENGTH_LONG);
This doesn't work either.
Upvotes: 0
Views: 1453
Reputation: 11316
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("plain/text");
intent.putExtra(Intent.EXTRA_EMAIL, new String[]
{ RECEIVER_EMIAL_ID });
// intent.putExtra(Intent.EXTRA_SUBJECT, "subject");
// intent.putExtra(Intent.EXTRA_TEXT, "mail body");
startActivity(Intent.createChooser(intent, "Choose mail client"));
Upvotes: 0
Reputation: 4255
Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, new String[]{strEmail});
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT,"subject");
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, "");
startActivity(Intent.createChooser(emailIntent, "Send mail..."));
Upvotes: 0
Reputation: 3820
You need to configure an email account in your default Email application.
Intent email = new Intent(Intent.ACTION_SEND);
email.setType("plain/text");
email.putExtra(Intent.EXTRA_EMAIL,
new String[] { [email protected]) });
email.putExtra(Intent.EXTRA_SUBJECT, "");
email.putExtra(Intent.EXTRA_TEXT,"");
startActivity(Intent.createChooser(email,
"Choose an Email client :"));
Upvotes: 2
Reputation: 3010
protected void sendEmail() {
Log.i("Send email", "");
String[] TO = {"[email protected]"};
String[] CC = {"[email protected]"};
Intent emailIntent = new Intent(Intent.ACTION_SEND);
emailIntent.setData(Uri.parse("mailto:"));
emailIntent.setType("text/plain");
emailIntent.putExtra(Intent.EXTRA_EMAIL, TO);
emailIntent.putExtra(Intent.EXTRA_CC, CC);
emailIntent.putExtra(Intent.EXTRA_SUBJECT, "Your subject");
emailIntent.putExtra(Intent.EXTRA_TEXT, "Email message goes here");
try {
startActivity(Intent.createChooser(emailIntent, "Send mail..."));
finish();
Log.i("Finished sending email...", "");
} catch (android.content.ActivityNotFoundException ex) {
Toast.makeText(MainActivity.this,
"There is no email client installed.", Toast.LENGTH_SHORT).show();
}
Try This It might Help U
Upvotes: 5