On some phones (HTC Desire S with Gingerbread and Galaxy Nexus) the following intent does not start the default mail client (com.android.mail).
viewIntent = new Intent(Intent.ACTION_SEND);
viewIntent.setType("plain/text");
Is there any way to find out which intent can be used to start the default mai client?
Email correct mime type is message/rfc822. text/plain should work too, but may trigger other handlers. plain/text is incorrect.
Also, ACTION_SENDTO is better if you are passing email addresses as parameters.
you can use like below :
Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
emailIntent.setType("plain/text");
emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL,
new String[] { email_add });
startActivity(emailIntent);
try this way..
Intent emailIntent = new Intent(Intent.ACTION_SEND);
String toMail[] = {"email id"};
emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL,toMail);
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "subject");
emailIntent.setType("plain/text");
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, "body");
startActivity(emailIntent);
In the end I had to change my intent to using a "mailto:" link instead of using intent extras to make it work on the HTC.
More details can be found here: Only Email apps to resolve an Intent
Related
when using ACTION_SEND to send emails, is there a way to check if result was successful?
here is my code sample:
Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
emailIntent.setType("plain/text");
emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL,
new String[] { "abc#xyz.com" });
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT,
"Subject of the Mail");
emailIntent.putExtra( android.content.Intent.EXTRA_TEXT,
"This is my sample Mail");
startActivity(Intent.createChooser(emailIntent, "Email:"));
Based on this posting: Get Mail Sent Notification in onActivityResult "Android" it sounds like the problem is that there is no guarantee that the client responsible for handling the intent is going to setActiviyResult, so there's no one way to get it. You'll have to check to see if the client that is handling the intent will send back a status.
I want to send the email from my android app. If i m using
Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
It is opening skype,bluetooth along with the mail client
and if i use
Intent emailIntent = new Intent(android.content.Intent.ACTION_SENDTO);
then it is only opening mail client,but in the text body it is adding %20%20 when there is new line
Which approach is suitable to get only mail client and body of the mail containing new lines and spaces.
Try sending it as below:
String subject = "mail subject";
String body = "whatever the mail content is. may include html tags too";
Intent intMail = new Intent(Intent.ACTION_SEND);
intMail.setType("message/rfc822");
intMail.putExtra(Intent.EXTRA_SUBJECT, subject);
intMail.putExtra(Intent.EXTRA_TEXT, Html.fromHtml(body));
startActivity(Intent.createChooser(intMail, "Send Email..."));
Try to use this code. You can keep subject, body etc as optional. It only opens email client and gives right output.
final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
emailIntent.setType("message/rfc822");
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, subject);
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, Body);
startActivity(Intent.createChooser(emailIntent, "Email:"));
I have set the receiver email address but when I tried to use it on my phone the receiver address is empty and you have to fill it on manually. I think the code is fine I don't know what the problem
CODE:
Intent mail = new Intent(android.content.Intent.ACTION_SEND);
mail.putExtra(android.content.Intent.EXTRA_EMAIL, "..#gmail.com");
mail.setType("plain/text");
startActivity(mail);
Try to fill all the available options like Subject, Text.
final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
emailIntent.setType("plain/text");
emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, "Receiver#gmail.com");
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "Your Subject Here");
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, "Body Part here");
startActivity(emailIntent);
Hope you have given all the permissions Correctly.
Some references. Link 1, Link 2
String[] reciver = new String[]{
"reciver01#gmail.com",
"reciver02#gmail.com",
...
};
mailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, reciver);
Maybe you should insert the receiver email here:
mail.putExtra(android.content.Intent.EXTRA_EMAIL, "receiver#gmail.com");
I just can't seem to get the e-mail sending working in Android.
Probably something stupid but I can't find it:
final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
emailIntent.setType("text/plain")
.putExtra(android.content.Intent.EXTRA_EMAIL,new String[] { "jb#mail.anykey.co.il" })
.putExtra(android.content.Intent.EXTRA_SUBJECT,"Exception in Yaniv!")
.putExtra(android.content.Intent.EXTRA_TEXT,"test");
ApplicationControllerBase.getMyApplicationContext().startActivity(Intent.createChooser(emailIntent,
"Send mail...").addFlags(Intent.FLAG_ACTIVITY_NEW_TASK));
I am not getting any error or exception on the startActivity command.
=======
Edit:
Seems that this is the same problem as this guy is having: Android: How to start an activity from an UncaughtExceptionHandler set in application
setType should be plain/text
try with the following code
final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
emailIntent.setType("plain/text");
emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, new String[]{"webmaster#website.com"});
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "mySubject");
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, "myBodyText");
startActivity(Intent.createChooser(emailIntent, "Send mail..."));
I've searched Google for this, but have only found similar examples--not exactly what I need. I simply need to start messaging (SMS) and email intents from my app with their "to" fields already populated. So I need to send a number with the sms intent and an email address with the email intent. Any help would be appreciated.
For the e-mail part :
Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, new String[] {"foo#bar.com"});
emailIntent.setType("text/plain");
startActivity(Intent.createChooser(emailIntent, "Send a mail ..."));
from Only Email apps to resolve an Intent
String recepientEmail = ""; // either set to destination email or leave empty
Intent intent = new Intent(Intent.ACTION_SENDTO);
intent.setData(Uri.parse("mailto:" + recepientEmail));
startActivity(intent);
will filter out all non-email applications.