Monday, March 11, 2013

Lanuch Email available client in phone / Send Email from your application

Android application can send email from available email clients in your phone.  For launching the email clients, simply pass the "ACTION_SEND" in intent constructor and add some extra to intents. You also have to set type of the contents.

Example:

Intent emailClient= new Intent(Intent.ACTION_SEND);
emailClient.putExtra(Intent.EXTRA_EMAIL, "email@domain.com");
emailClient.putExtra(Intent.EXTRA_SUBJECT, "Hi");
emailClient.putExtra(Intent.EXTRA_TEXT, "How r u!");
emailClient.setType("message/rfc822");
startActivity(Intent.createChooser(emailClient,"Title")); 

You need to add Internet permission in manifest file like this

 <uses-permission android:name="android.permission.INTERNET" />


Note: You can test this code only on phone. Emulator can not send email and will generate error.

No comments:

Post a Comment