Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sending email from android app

Tags:

android

email

I need to provide feature for users where users can share some data by sending email. I used below code.

Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
emailIntent.setType("text/html");
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "testing email send.");
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, Html.fromHtml("<b>this is html text in email body.</b>"));
startActivity(Intent.createChooser(emailIntent, "Email to Friend"));

This shows mail app, gmail and bluetooth for user to choose. I dont want user to show bluetooth in this list. What i need to do ? I have facebook app, which does same thing, but doesn't show bluetooth in the list. I need to do the same.

like image 650
Umakant Patil Avatar asked Jan 17 '11 09:01

Umakant Patil


People also ask

Why can't I send emails from my Android phone?

If you can't send email try the following: Open your email application. Tap Menu and then Account Settings. If the settings are correct try setting the Security type to None and the Port to 25 or 587.

Does Android have a built in Mail app?

The Gmail app is Google's new default email app that is pre-installed on many Android devices.

How do I send an email without Gmail?

I use http://sendgrid.com/ to send emails from the cloud, they have a free option. there is also sample code on how to send emails, I re-factored their code so I could call it from other places.


1 Answers

You can use the ACTION_SENTTO instead of ACTION_SEND to get the list of e-mail clients. I tried this on HTC Wildfire which had default e-mail client, GMail app and k9-3.508-release installed. When I ran your code with ACTION_SENDTO, I got list of above mentions 3 e-mail clients and not bluetooth no matter if bluetooth was enabled or disabled. I tried it both when the bluetooth was enabled and when bluetooth was disabled. It worked well for me.

Intent emailIntent = new Intent(android.content.Intent.ACTION_SENDTO);
emailIntent.setType("text/html");
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "testing email send.");
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, Html.fromHtml("<b>this is html text in email body.</b>"));
startActivity(Intent.createChooser(emailIntent, "Email to Friend"));
like image 76
Ashish Pathak Avatar answered Sep 30 '22 15:09

Ashish Pathak