3

I want to send an email from my email id to another one. I found some code for sending email, but it should navigate to another screen for Google signing in. I don't want that. My requirement is it should automatically send mails to the specified email id from my email id. How can I do that without signing in any other account? Following are my codes :

public class EmailSending extends Activity
   {
        @Override
        public void onCreate(Bundle savedInstanceState) 
        {
           super.onCreate(savedInstanceState);
           setContentView(R.layout.main);
           EditText edtEmail=(EditText)findViewById(R.id.edtEmail);
           EditText edtSubject=(EditText)findViewById(R.id.edtSubject);
           EditText edtContent=(EditText)findViewById(R.id.edtContent);
           EditText edtMyMailId=(EditText)findViewById(R.id.edtMyMail);

           final String adminMailId=edtEmail.getText().toString();
           final String adminSubject=edtSubject.getText().toString();
           final String adminContent=edtContent.getText().toString();
           final String myMailId=edtMyMailId.getText().toString();


              Button btnSubmit = (Button) findViewById(R.id.btnSubmit);
              btnSubmit.setOnClickListener(new View.OnClickListener()
           {
                public void onClick(View view)
                {
                        //SENDING EMAIL 
                         Intent emailIntent=new Intent(Intent.ACTION_SEND);
                         emailIntent.setType("plain/text");
                         emailIntent.putExtra(Intent.EXTRA_EMAIL, new String[]{adminMailId});
                         emailIntent.putExtra(Intent.EXTRA_SUBJECT,adminSubject);
                         emailIntent.putExtra(Intent.EXTRA_TEXT, adminContent);
                         EmailSending.this.startActivity(Intent.createChooser(emailIntent, "Sending mail.."));



         Toast.makeText(getBaseContext(), "Email has been sent!", 1).show();

             }});

    }

Please help me.. Thank you..

Jomia
  • 3,414
  • 10
  • 46
  • 63

1 Answers1

1

With the current SDK capabilities, you cannot send emails automatically (without user intervention). The code above is intended to start an activity (screen) with the email details filled in and asking the user to hit the send button.

advantej
  • 20,155
  • 4
  • 34
  • 39