In Android we can send Email using following Code
Intent i = new Intent(Intent.ACTION_SEND);
i.setType("message/rfc822");
i.putExtra(Intent.EXTRA_EMAIL , new String[]{"recieveremail@gmail.com"});
i.putExtra(Intent.EXTRA_SUBJECT, "Subject of Mail");
i.putExtra(Intent.EXTRA_TEXT , "The Message Body");
try {
startActivity(Intent.createChooser(i, "Sending mail..."));
}
finally {
// Code to execute when unable to send Email
}
Intent i = new Intent(Intent.ACTION_SEND);
i.setType("message/rfc822");
i.putExtra(Intent.EXTRA_EMAIL , new String[]{"recieveremail@gmail.com"});
i.putExtra(Intent.EXTRA_SUBJECT, "Subject of Mail");
i.putExtra(Intent.EXTRA_TEXT , "The Message Body");
try {
startActivity(Intent.createChooser(i, "Sending mail..."));
}
finally {
// Code to execute when unable to send Email
}
Hello
ReplyDeleteCould you also tell us how to mail attachments?
To attache files in Email yuu need to use Intent.EXTRA_STREAM
DeleteFor Ex:
ArrayList uris = new ArrayList();
i.putParcelableArrayListExtra(Intent.EXTRA_STREAM, uris);
startActivityForResult(Intent.createChooser(i, "Sending multiple attachment"), 12345);
Hi.
ReplyDeleteCan you please tell how to send mail directly from the app.. without using any mail client.
Regards.
This comment has been removed by the author.
ReplyDeletePlease anyone can tell how to send mails from app....without client interference. ...please
ReplyDelete