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.
Related
I had developed the email sending functionality in my Application where I need to send the email with the specified subject. I have done that but I need that as soon as I click the Email Icon It sets some particular piece of Information in the Body part of the email format. It could be any information that I have with me.
Is it possible to set the data in the Email Body in android, I don't want to write anything in the Body of the mail.
Thanks,
DavidBrown
final Intent emailIntent = new Intent( android.content.Intent.ACTION_SEND);
emailIntent.setType("plain/text");
emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL,
new String[] { "abc#gmail.com" });
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT,
"Email Subject");
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT,
"Email Body");
startActivity(Intent.createChooser(
emailIntent, "Send mail..."));
Intent.EXTRA_TEXT is what you are looking for.
Try this
intent.putExtra(Intent.EXTRA_TEXT ,
"body of email -- add text what you want ");
This can be useful for you..
Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
emailIntent.setType("text/plain");
emailIntent.putExtra(Intent.EXTRA_EMAIL,new String[]{"support#arboristapp.com"});
emailIntent.putExtra(Intent.EXTRA_CC, new String[]{""});
emailIntent.putExtra(Intent.EXTRA_BCC, new String[]{""});
emailIntent.putExtra(Intent.EXTRA_SUBJECT, "Subject of email");
emailIntent.putExtra(Intent.EXTRA_TEXT, "This is test app");
startActivity(emailIntent);
Not very clear what exactly you want. But if you need to add text/data in email body use
intent.putExtra(Intent.EXTRA_TEXT, "This data will appear in email body");
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
In my project i have to send mail to company id.First i tried code with my email id. but its not showing anything.my code is here
Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
String aEmailList[] = { "my emailid used here" };
emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, aEmailList);
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "My subject");
emailIntent.setType("plain/text");
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, "My message body.");
startActivity(emailIntent);
Log.e("name","msg sent success fully");
in my logcat i saw "msg sent success fully" message also. but i didnt get any mail in my mail id.
am i did any wrong code or am i need to add any permissions in manifest file.
Your code seems fine except there is no need to use "android.content." and there is no FLAG_ACTIVITY_NEW_TASK What should happen is that your email program should start with these data already entered. Have you setup your email client on that device?
Here is a code example that works and sends an image selected from a gallery as an attachment:
Intent i = new Intent(Intent.ACTION_SEND);
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
i.setType("image/png");
i.putExtra(Intent.EXTRA_STREAM, Uri.parse("file://" + mUrls[imageSelected].toString()));
startActivity(i);
I'm trying to have the user e-mail me when they click a button, and use this code to do so. While it works, it brings up a lot of other applications that cant handle e-mail, like Twitter and Facebook. What's missing?
String[] email = {"evan#example.com"};
Intent sendIntent = new Intent(Intent.ACTION_SEND);
sendIntent.setType("text/plain");
sendIntent.putExtra(Intent.EXTRA_EMAIL,email);
context.startActivity(sendIntent);
final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
emailIntent .setType("plain/text");
emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, new String[]{"evan#example.com"});
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "My Subject");
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, msg);
startActivity(Intent.createChooser(emailIntent, "Send mail"));
// start the activity
context.startActivity(sendIntent);
// start the activity asking the user how to send the email
context.startActivity(Intent.createChooser(sendIntent, "Email:"));
So you need to remove the last line.
see http://developer.android.com/reference/android/content/Intent.html
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..."));