Send Email Intent

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

    This is the proper way to send the e-mail intent according to the Android Developer Official Documentation

    Add these lines of code to your app:

    Intent intent = new Intent(Intent.ACTION_SEND);//common intent 
    intent.setData(Uri.parse("mailto:")); // only email apps should handle this
    

    Optional: Add the body and subject, like this

    intent.putExtra(Intent.EXTRA_SUBJECT, "Your Subject Here");
    intent.putExtra(Intent.EXTRA_TEXT, "E-mail body" );
    

    You already added this line in your question

    intent.putExtra(Intent.EXTRA_EMAIL, new String[]{"donotemail-stack-overflow@unitmeasure-app.xyzed"});
    

    This will be the recipient's address, meaning the user will send you (the developer) an e-mail.

提交回复
热议问题