Sending email from android app

前端 未结 3 1192
旧巷少年郎
旧巷少年郎 2020-12-05 14:58

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.Inte         


        
相关标签:
3条回答
  • 2020-12-05 15:24

    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"));
    
    0 讨论(0)
  • 2020-12-05 15:40

    Try adding the EXTRA_EMAIL to your intent, maybe bluetooth can be connected to ACTION_SEND but not to the same action if an email is to be send.

    See here:
    http://developer.android.com/reference/android/content/Intent.html#ACTION_SEND and here
    http://developer.android.com/reference/android/content/Intent.html#EXTRA_EMAIL

    Just a rough guess ...

    0 讨论(0)
  • 2020-12-05 15:42

    Try using this type instead:

    emailIntent.setType("message/rfc822");
    
    0 讨论(0)
提交回复
热议问题