Send e-mail direct from App

Asked

Viewed 2,354 times

1

can send an email with a suggestion directly from the App, without opening an external application, like Gmail? Example:

A field where one puts the email and another field it by the suggestion and a send button. After all the fill when she touches the send button, the email is fired, without opening the default email application that is configured on the smartphone?

I did a test with the code below, it works however it opens the external application.

 FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
    fab.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            Snackbar.make(view, "Envie sua sugestão para o nosso email", Snackbar.LENGTH_LONG)
                    .setAction("Enviar", new View.OnClickListener() {
                        @Override
                        public void onClick(View v) {
                            Intent email = new Intent(Intent.ACTION_SEND);
                            email.setData(Uri.parse("mailto"));
                            email.setType("message/rfc822");
                            email.putExtra(Intent.EXTRA_EMAIL,
                                    new String[]{"aquieucolocomeuemaildecontato"});
                            email.putExtra(Intent.EXTRA_SUBJECT,
                                    "Sugestão: ");
                            email.putExtra(Intent.EXTRA_TEXT, "Olá " + "");
                            startActivity(Intent.createChooser(email, "ENVIAR E-MAIL"));
                        }
                    }).show();
        }
    });

}
  • Follow this tutorial and you will be able to send email directly from the app without having to use other external applications. link

  • @Henqsan visualized here, I will test later but already helped here. Thank you

1 answer

0


Yes, this is possible! But you will need to develop a API to do this for you. This api will run on a server/cloud (which will require the mobile phone to have an internet connection) that will receive the call from your application containing the information that will be sent by email and will send it to you.

With a quick search you can figure out how to do this using the language of your preference, I will list two links that can help you implement this in a very easy way:

If you want to make your life easier, use the Sendgrid or the Mailgun to assist you with these shipments

Browser other questions tagged

You are not signed in. Login or sign up in order to post.