1

Intent opens gmail with subjects but with no text. Where is mistake? Please help. I spent for this 2 hours). Subject fields are plain, but no text. I added method with returning String.

public void submitOrder(View view) {
    
    String message = total();
  
    Intent intent = new Intent(Intent.ACTION_SENDTO, Uri.parse("mailto:" + "ded-logoped@ukr.net"));
    intent.putExtra(Intent.EXTRA_SUBJECT, getString(R.string.java_order_for) + " " + pseudoname());
    intent.putExtra(Intent.EXTRA_TEXT, message);
    if (intent.resolveActivity(getPackageManager()) != null) {
        startActivity(Intent.createChooser(intent, getString(R.string.сhoose_email_app)));}

}




 public String total(){
        CheckBox checkBoxmilk = findViewById(R.id.mychb);
        CheckBox checkBoxchoco = findViewById(R.id.jrfen);
        if (checkBoxchoco.isChecked()){
            chocolad = chocolad+2;

        }
        else {
            chocolad = chocolad-chocolad;
        }

        if (checkBoxmilk.isChecked()){
            milk = milk+1;
        }
        else {
            milk = milk-milk;}

        int all = quantity*price+milk+chocolad;

        String together = pseudoname()+" заказал "+quantity+" cups "+"\n" +"add milk? "+check()+"\n"+"add chocolate? "+check2()+"\n"+"Total "+(NumberFormat.getCurrencyInstance().format(all));
        return together;





       
  • Does this answer your question? [Android: Using Intent to send email - only offering email applications doesnt work](https://stackoverflow.com/questions/41429843/android-using-intent-to-send-email-only-offering-email-applications-doesnt-wo/62555270#62555270) – Torkel Velure Jul 06 '20 at 10:59
  • The above code snippet works fine. Please check if the variable 'message' is empty if the email body does not show up. – ACR Jul 06 '20 at 11:30

1 Answers1

0

Have a look at this article which describes more details about using Intents to send email:

https://medium.com/@cketti/android-sending-email-using-intents-3da63662c58f

You probably want to use ACTION_SEND instead of ACTION_SENDTO or you'll need to add your message text and other data as query parameters to the URI instead of putting them in "extras".

David Wasser
  • 93,459
  • 16
  • 209
  • 274