Send Email Intent

前端 未结 30 3692
忘掉有多难
忘掉有多难 2020-11-22 07:27
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType(\"text/html\");
intent.putExtra(Intent.EXTRA_EMAIL, \"emailaddress@emailaddress.com\");
intent.putExtr         


        
30条回答
  •  庸人自扰
    2020-11-22 08:03

    The accepted answer doesn't work on the 4.1.2. This should work on all platforms:

    Intent emailIntent = new Intent(Intent.ACTION_SENDTO, Uri.fromParts(
                "mailto","abc@gmail.com", null));
    emailIntent.putExtra(Intent.EXTRA_SUBJECT, "Subject");
    emailIntent.putExtra(Intent.EXTRA_TEXT, "Body");
    startActivity(Intent.createChooser(emailIntent, "Send email..."));
    

    Update: According to marcwjj, it seems that on 4.3, we need to pass string array instead of a string for email address to make it work. We might need to add one more line:

    intent.putExtra(Intent.EXTRA_EMAIL, addresses); // String[] addresses
    

    Ref link

提交回复
热议问题