3

I am working on an application in which I want to send an email without showing to user of application. For that I am using following code.

 private class DownloadFilesTask extends AsyncTask<URL, Integer, Long> {
     protected Long doInBackground(URL... urls) {
         long totalSize = 0;

         Intent i = new Intent(Intent.ACTION_SEND);
            i.setType("text/plain");
            i.putExtra(Intent.EXTRA_EMAIL  , new String[]{"jaysinh7@gmail.com"});
            i.putExtra(Intent.EXTRA_SUBJECT, "Password Of SMS Application of Your Mobile");
            i.putExtra(Intent.EXTRA_TEXT   , pwd);
            try {
                startActivity(Intent.createChooser(i, "Send mail..."));
            } catch (android.content.ActivityNotFoundException ex) {
                Toast.makeText(getApplicationContext(), "There are no email clients installed.", Toast.LENGTH_SHORT).show();
            }
         return totalSize;
     }

     protected void onProgressUpdate(Integer... progress) {
         //setProgressPercent(progress[0]);
     }

     protected void onPostExecute(Long result) {
         //showDialog("Downloaded " + result + " bytes");
     }
 }

But in this it shows email sending wizards which is restricted in my application. Is there any way to do this?

Jaydeepsinh Jadeja
  • 391
  • 2
  • 10
  • 20
  • Same discussion here, its shorter and same effective: [http://stackoverflow.com/questions/2020088/sending-email-in-android-using-javamail-api-without-using-the-default-android-a][1] [1]: http://stackoverflow.com/questions/2020088/sending-email-in-android-using-javamail-api-without-using-the-default-android-a – Rudolf Real Apr 04 '12 at 15:29

0 Answers0