Suresh
Suresh

Reputation: 8353

Send Email With only Email client application in android

I want to implement an option to send email. Right now i can send email but problem is, Android shows many applications to send such as bluetooth, facebook, message,etc which is not required. I need to avoid this and show only email client application.

Intent intent = new Intent(Intent.ACTION_SEND); 
String[] emails = {"[email protected]"}; 
intent.putExtra(Intent.EXTRA_EMAIL, emails); 
intent.putExtra(Intent.EXTRA_STREAM, uri); 
intent.putExtra(Intent.EXTRA_SUBJECT, "Test App"); 
intent.putExtra(Intent.EXTRA_TEXT, "Email Body"); 
intent.setType("message/rfc822"); 
startActivity(intent);

If any one knows to how to achieve this please let me know

Upvotes: 2

Views: 1570

Answers (2)

beyerss
beyerss

Reputation: 1352

Intent intent = new Intent(Intent.ACTION_SENDTO, Uri.parse("mailto:[email protected]);    
intent.putExtra(Intent.EXTRA_SUBJECT, "Test App");  
intent.putExtra(Intent.EXTRA_TEXT, "Email Body");
startActivity(intent);

Credit goes to Adams Bros Blogs but he does mention in his post that this only worked for gmail for him. See if you have any success with it. He does show another way of doing this that worked for him.

Upvotes: 3

CommonsWare
CommonsWare

Reputation: 1006724

To send email to a specific address, use ACTION_SENDTO and a mailto: Uri in your Intent supplied to startActivity(). Or, implement your own email client, using the JavaMail port for Android.

Upvotes: 2

Related Questions