Reputation: 315
I have a requirement that I need to send email from my application, I am using below code to send email...
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("Text/Plain");
intent.putExtra(Intent.EXTRA_EMAIL, new String[]{[email protected]});
intent.putExtra(Intent.EXTRA_TEXT, "hello..");
startActivity(Intent.createChooser(intent, email_chooser_title));
The above code launching the email composer. But after I press on send button , I can see one toast message "Message Sending" , But my message not sent.
pl. help me to figure out where I did wrong in this, or let me know if any alternative to solve this.. thanks.
Upvotes: 0
Views: 286
Reputation: 2082
Intent i = new Intent(Intent.ACTION_SEND);
//i.setType("text/plain"); //use this line for testing in the emulator
i.setType("message/rfc822") ; // use from live device
i.putExtra(Intent.EXTRA_EMAIL, new String[]{"[email protected]"});
i.putExtra(Intent.EXTRA_SUBJECT,"subject goes here");
i.putExtra(Intent.EXTRA_TEXT,"body goes here");
startActivity(Intent.createChooser(i, "Select email application."));
Upvotes: 1