1

Iv'e tried creating some kind of password reminder that sends the password to the user email. instead whenever I try sending this mail through the app I'm only get to the send SMS page. I'm using the latest android studio version.

    public void ForgetPasswordEvent (View view) {
        //AlertDialog recovery = new AlertDialog();
        final AlertDialog.Builder builder = new AlertDialog.Builder(this);
        builder.setTitle("Please enter your registered email");
// Set up the input
        final EditText input = new EditText(this);
// Specify the type of input expected;
        input.setInputType(InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS);
        builder.setView(input);
// Set up the buttons
        builder.setPositiveButton("Send", new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                m_Text= input.getText().toString();
                Log.i("Send email", "");

//              String[] TO = {m_Text.toString()};
                String[] TO = {"erez@manageyourtrip.com"};
                String[] CC = {"erez@manageyourtrip.com"};
                Intent emailIntent = new Intent(Intent.ACTION_SEND);
                emailIntent.setData(Uri.parse("mailto:"));
                emailIntent.setType("text/plain");


                emailIntent.putExtra(Intent.EXTRA_EMAIL, TO);
                emailIntent.putExtra(Intent.EXTRA_CC, CC);
                emailIntent.putExtra(Intent.EXTRA_SUBJECT, "MYT GuideApp password recovery");
                emailIntent.putExtra(Intent.EXTRA_TEXT, "Your password is 123456");

                try {
                    startActivity(createChooser(emailIntent, "Send mail..."));
                    finish();
                    Log.i("Finished sending email", "");
                } catch (android.content.ActivityNotFoundException ex) {
                    Toast.makeText(MainActivity.this,
                            "There is no email client installed.", Toast.LENGTH_SHORT).show();
                }

            }
        });
        builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                dialog.cancel();
            }
        });

        builder.show();
Erez Priel
  • 65
  • 1
  • 10
  • You should not send the password. You should reset it and make the user create a new one. You should not be able to get the password if you want security on your app. – gian1200 Aug 30 '15 at 14:24
  • In this specific case i want to send the old password (in this case 1-6). But this is not the question. How can I send a mail directly from my app? – Erez Priel Aug 31 '15 at 05:55
  • possible duplicate of [How can I send emails from my Android application?](http://stackoverflow.com/questions/2197741/how-can-i-send-emails-from-my-android-application) – gian1200 Aug 31 '15 at 06:01

1 Answers1

0

setType("text/plain") is too "wide".

You should use something like:

setType("message/rfc822")

Disclaimer: I'm still not in favor of this kind of functionality. I wouldn't use (or recommend) an app which is able to send my my password.

Source: Another question asking the same thing

Community
  • 1
  • 1
gian1200
  • 3,670
  • 2
  • 30
  • 59
  • Ok Iv'e fixed the problem.. the e-mail account was not configured correctly. Now how can i send an auto-email? the app opens a new mail form with the details Iv'e written (receiver mail, subject and text). – Erez Priel Aug 31 '15 at 10:26