Send Email when you press a button

0

I'm doing an application that consists of, at the push of a button a scheduled email is sent automatically without me having to log in to gmail to push "send"

Until then I put this code together and it is doing everything but sending it without having to go to gmail

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    button = findViewById(R.id.button);
    button.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            try {
                Intent email = new Intent(Intent.ACTION_SEND);

                email.setData(Uri.parse("mailto"));
                email.setType("message/rfc822");
                email.putExtra(Intent.EXTRA_EMAIL,
                        new String[]{"[email protected]"});
                email.putExtra(Intent.EXTRA_SUBJECT,
                        "Assunto do email ");
                email.putExtra(Intent.EXTRA_TEXT, "mensagem que quero enviar ");
                //startActivity(email);
                email.putExtra(Intent.ACTION_SEND, email);
            }catch (Exception e){
                e.printStackTrace();
                Toast.makeText(MainActivity.this, e.getMessage().toString(), Toast.LENGTH_SHORT).show();
            }
        }
    });
}

What should I add to it to send without having to enter email

    
asked by anonymous 07.02.2018 / 18:58

0 answers