0

i just want to send an email with attachments. i just done everything based on the developer site.

https://developer.android.com/training/sharing/send.html

it opening the email intent chooser but when i click on any of the app in chooser it doesn't open any app to send an mail with attachments. any thing i want to add in Android Manifest file.

helps are more appreciated.

and i got message from log too:

    06-02 11:49:36.751: W/ContextImpl(16313): Calling a method in the system process without a qualified user: android.app.ContextImpl.sendBroadcast:830 com.samsung.android.share.SShareLogging.insertLog:74 com.android.internal.app.ResolverActivity.onTargetSelected:1223 com.android.internal.app.ChooserActivity.onTargetSelected:386 com.android.internal.app.ResolverActivity.startSelected:1040 
    06-02 11:49:36.771: W/AudioPolicyIntefaceImpl(3069): Skipped to add effects on session 2024
user3546693
  • 364
  • 3
  • 18

2 Answers2

0

Use this code, this may helpful for you

Intent emailIntent = new Intent(Intent.ACTION_SENDTO);
emailIntent.setData(Uri.parse("mailto:" + "" + receiver_mail);
emailIntent.putExtra(Intent.EXTRA_SUBJECT, "Subject");
emailIntent.putExtra(Intent.EXTRA_TEXT, "body");

try {
startActivity(Intent.createChooser(emailIntent, "Send email using..."));
} 
catch (android.content.ActivityNotFoundException ex) 
{
Toast.makeText(ClusteringMinimaTest.this, "No email clients installed.", Toast.LENGTH_SHORT).show();
}
Ravi Varma
  • 66
  • 3
0

Try below code for that.

       try { 
              final Intent emailIntent = new Intent(
                                     android.content.Intent.ACTION_SEND);
              emailIntent.setType("plain/text");
              emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL,
                                     new String[] { "YOUR_RECIEPINTS" });
              emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT,
                                     "YOUR_SUBJECT");
               if (URI != null) {
                         emailIntent.putExtra(Intent.EXTRA_STREAM, URI);
               }
                emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, "YOUR_MESSAGE");

             this.startActivity(Intent.createChooser(emailIntent,
                                     "Sending email..."));

         } catch (Throwable t) {
                    Toast.makeText(this,
                                     "Request failed try again: " + t.toString(),
                                     Toast.LENGTH_LONG).show();
         }

If it give any permission exception then use below permissions for that,

   <uses-permission android:name="android.permission.INTERNET" />
   <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
   <uses-permission android:name="android.permission.READ_INTERNAL_STORAGE" />
   <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
Vickyexpert
  • 3,147
  • 5
  • 21
  • 34