How do I know if the email was actually sent?

2

I am using a code for sending e-mail, I call the e-mail service and choose a certain e-mail that is already configured on the mobile phone. It's all working normally, however I want to put an alert after sending this email but I can not display it at the right time because I do not have a positive or negative response from sending that email. How do I know that the email was actually sent? Here's my code ...

                Intent sendEmail = new Intent(Intent.ACTION_SEND);
                sendEmail.putExtra(Intent.EXTRA_EMAIL, new String[]{to});
                sendEmail.putExtra(Intent.EXTRA_SUBJECT, assunto);
                sendEmail.putExtra(Intent.EXTRA_CC, new String[]{email});
                sendEmail.putExtra(Intent.EXTRA_STREAM, imageUri);
                sendEmail.putExtra(Intent.EXTRA_TEXT, "texto...");

                sendEmail.setType("message/rfc822");

                startActivity(Intent.createChooser
                     (sendEmail, "Enviar o e-mail com: "));

                AlertDialog.Builder alert = new AlertDialog.Builder(activity);
                alert.setTitle("Obrigado pelo contato !");
                alert.setMessage("texto...");
                alert.setPositiveButton("OK", null);
                alert.show();
    
asked by anonymous 26.11.2015 / 14:40

1 answer

1

The responsibility of informing whether or not the email was sent is from the activity that your attempt invoked. So there is no need for you to handle the success or error case of sending the email. It will inform the user if the action is not completed successfully.

    
27.11.2015 / 03:33