Send Email Intent
when you will change your intent.setType like below you will get
intent.setType("text/plain");
Use android.content.Intent.ACTION_SENDTO
to get only the list of e-mail clients, with no facebook or other apps. Just the email clients.
Ex:
new Intent(Intent.ACTION_SENDTO);
I wouldn't suggest you get directly to the email app. Let the user choose his favorite email app. Don't constrain him.
If you use ACTION_SENDTO, putExtra does not work to add subject and text to the intent. Use Uri to add the subject and body text.
EDIT:
We can use message/rfc822
instead of "text/plain"
as the MIME type. However, that is not indicating "only offer email clients" -- it indicates "offer anything that supports message/rfc822 data". That could readily include some application that are not email clients.
message/rfc822
supports MIME Types of .mhtml, .mht, .mime
Using Android Intent.ACTION_SEND for sending email
Intent email = new Intent(android.content.Intent.ACTION_SEND);
email.setType("application/octet-stream");
EDIT:
You could try setting the type to "message/rfc822"
as well.
try this...
ACTION_SEND force sending with email
Try to setType message/rfc822
instead of text/plain
How to send emails from my Android application?
The best (and easiest) way is to use an Intent
:
Intent i = new Intent(Intent.ACTION_SEND);
i.setType("message/rfc822");
i.putExtra(Intent.EXTRA_EMAIL , new String[]{"recipient@example.com"});
i.putExtra(Intent.EXTRA_SUBJECT, "subject of email");
i.putExtra(Intent.EXTRA_TEXT , "body of email");
try {
startActivity(Intent.createChooser(i, "Send mail..."));
} catch (android.content.ActivityNotFoundException ex) {
Toast.makeText(MyActivity.this, "There are no email clients installed.", Toast.LENGTH_SHORT).show();
}
Otherwise you'll have to write your own client.
Opening email client via Intent (but not to send a message)
I think you should replace Intent.ACTION_SEND
to Intent.ACTION_VIEW
,
i am sure this will work as this will prompt with list of application which support MIME type "message/rfc822"
so it will include your default email client in your device other than gmail app.
How about this code:
final Intent emailLauncher = new Intent(Intent.ACTION_VIEW);
emailLauncher.setType("message/rfc822");
try{
startActivity(emailLauncher);
}catch(ActivityNotFoundException e){
}
Action send mail to with file Android 11
solved with replacing:
Intent email_intent = new Intent(Intent.ACTION_SEND);
email_intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
and in <manifest> </manifest>
putting:
<queries>
<intent>
<action android:name="android.intent.action.SEND"/>
<data android:mimeType="*/*" />
</intent>
</queries>
Android\Intent: Send an email with image attachment
Try below code...
Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
emailIntent.setType("application/image");
emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, new String[]{strEmail});
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT,"Test Subject");
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, "From My App");
emailIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse("file:///mnt/sdcard/Myimage.jpeg"));
startActivity(Intent.createChooser(emailIntent, "Send mail..."));
Related Topics
How to Update My Adt in Eclipse
Edittext Seterror() with Icon But Without Popup Message
Inflateexception with Floatingactionbutton from Official Design Library
Configuration with Name 'Default' Not Found. Android Studio
Cannot Enable Gradle's Offline Mode on Android Studio 3.6
Android: What Are the Recommended Configurations for Proguard
Play Sound on Button Click Android
Android L's Ripple Effect - Touch Feedback for Buttons - Using Xml
Custom Dialog on Android: How to Center Its Title
What's Better? Notifydatasetchanged or Notifyitemchanged in Loop
Searchview's Oncloselistener Doesn't Work
How to Display a Route Between Two Geocoords in Google Maps
Check Whether Activity Is Active
Libpng Error: Not a Png File Error Showing in Android Studio
Icon in Menu Not Showing in Android
Get the Distance Between Two Geo Points