Here is a way by which you can send the email via android-intent.
The below code opens a dialog showing email related apps e.g. Gmail, Yahoo Mail etc. if installed in your device.
In case your device is not installed with mailing applications then it will go to catch block and show the appropriate message.
String subject="subject_title";
String mailBody="Hello, This is the text of my mail"
String[] receipentList ={"receiver1@gmail.com", "receiver2@yahoo.com"};
String[] ccReceipentList ={"receiver3@gmail.com", "receiver4@yahoo.com"};
Intent i = new Intent(Intent.ACTION_SEND);
i.setType("text/plain");
i.putExtra(Intent.EXTRA_EMAIL , receipentList);
i.putExtra(Intent.EXTRA_CC, ccReceipentList);
i.putExtra(Intent.EXTRA_SUBJECT, subject);
i.putExtra(Intent.EXTRA_TEXT , mailBody);
try
{
startActivity(Intent.createChooser(i, "Send mail..."));
}
catch (android.content.ActivityNotFoundException ex)
{
Toast.makeText(MyActivity.this, "No email clients available.", Toast.LENGTH_SHORT).show();
}
0 Comment(s)