Send Email Intent

前端 未结 30 3765
忘掉有多难
忘掉有多难 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:02

    Using intent.setType("message/rfc822"); does work but it shows extra apps that not necessarily handling emails (e.g. GDrive). Using Intent.ACTION_SENDTO with setType("text/plain") is the best but you have to add setData(Uri.parse("mailto:")) to get the best results (only email apps). The full code is as follows:

    Intent intent = new Intent(Intent.ACTION_SENDTO);
    intent.setType("text/plain");
    intent.setData(Uri.parse("mailto:IT@RMAsoft.NET"));
    intent.putExtra(Intent.EXTRA_SUBJECT, "Email from My app");
    intent.putExtra(Intent.EXTRA_TEXT, "Place your email message here ...");
    startActivity(Intent.createChooser(intent, "Send Email"));
    

提交回复
热议问题