0

I tried to send email automatically when i click on button but without success.

Here is my code to add my files and opening gmail (with intent). I need to send the email automatically when I click on the button. (uris object is ArrayList that I add a files)

How can I do it?

        public void onClick(View view)
        {
            try
            {
                    // Intent to send the email
                    Intent emailIntent = new Intent(Intent.ACTION_SEND_MULTIPLE);

                    // Set the type to 'email'
                    emailIntent .setType("vnd.android.cursor.dir/email");
                    String to[] = {"niravisrur1@gmail.com"};
                    emailIntent.putExtra(Intent.EXTRA_EMAIL, to);
                    // The attachment
                    emailIntent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, uris);
                    // The mail subject
                    startActivity(Intent.createChooser(emailIntent , "Send email..."));
                }
            }
            catch (Exception e)
            {
                Log.e("SendMail", e.getMessage(), e);
            }
Phantômaxx
  • 37,901
  • 21
  • 84
  • 115
  • Send e-mail [JavaMail API](https://stackoverflow.com/questions/2020088/sending-email-in-android-using-javamail-api-without-using-the-default-built-in-a/2033124#2033124) using Gmail authentication – MSD Feb 20 '18 at 11:40
  • you can open only email with pass email, text and title, but cant access gmail send button functionality, you have to manually press the button on gmail for send email. – Hemant Parmar Feb 20 '18 at 11:40

0 Answers0