I have written a code in which I am allowing user to send order via email to vendor [ShopOwner] along with their personal and cart item details, but here I am getti
Seem problem with android.content
which you passing with your putExtras
.
try something like below:
public Intent sendMail1() {
Intent messageIntent = new Intent(Intent.ACTION_SEND);
String aEmailList[] = { "rakesh@rocketmail.com" };
messageIntent.putExtra(Intent.EXTRA_EMAIL, aEmailList);
messageIntent.putExtra(Intent.EXTRA_SUBJECT, subject);
messageIntent.setType("text/html");
messageIntent.putExtra(Intent.EXTRA_TEXT,
Html.fromHtml(body.toString()));
return messageIntent;
}
Fire your intent like:
startActivity(Intent.createChooser(sendMail1(), "send mail"));
The error message shows:
ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.SEND typ=text/html flg=0x1 (has clip) (has extras) }
It means that the android system doesnt found any email sending activity to handle the intent created by you. Make sure you have email application installed in your device.
Also use the following code to send email,
Intent i = new Intent(Intent.ACTION_SEND);
i.setType("message/rfc822");
i.putExtra(Intent.EXTRA_EMAIL , new String[]{"recipient@example.com"});
i.putExtra(Intent.EXTRA_SUBJECT, "subject of email");
i.putExtra(Intent.EXTRA_TEXT , "body of email");
try {
startActivity(Intent.createChooser(i, "Send mail"));
} catch (android.content.ActivityNotFoundException ex) {
Toast.makeText(MyActivity.this, "There are no email applications installed.", Toast.LENGTH_SHORT).show();
}
Rakesh sorry for late reply, since 10 am i was trying to resolve your issue and i have tried several times and finally below code has worked:
i knew you got answer, but i have given many hours for my satisfaction i am placing my answer here, and brother i don't need points for this, because @SahilMahajanMj deserve this:
Intent i = new Intent(Intent.ACTION_SEND);
i.putExtra(Intent.EXTRA_EMAIL , new String[]{"rakesh@rocketmail.com"});
i.putExtra(Intent.EXTRA_SUBJECT, subject);
i.setType("message/rfc822");
i.putExtra(Intent.EXTRA_TEXT, Html.fromHtml(body.toString()));
try {
startActivity(Intent.createChooser(i, "Send email via :"));
} catch (android.content.ActivityNotFoundException ex) {
Toast.makeText(ArrowsActivity.this, "There are no email applications installed.", Toast.LENGTH_SHORT).show();
}