Skip to content Skip to sidebar Skip to footer

Email Not Sending From Android Application

I am developing in application in which there is one module of sending email. I have tried many tutorials but email is not sending and there is no exception or error there. I am sh

Solution 1:

please set the type as setType("application/octet-stream") instead of plain/text and also i request you to confirm that whether you had internet permission in your manifest file.

try the following code snippet which has setType ad application/octext-stream as i mentioned above

// Creating a Object for the Class Intent

Intent sendIntent;

// Since we want to send ,we are using ACTION_SEND

sendIntent = newIntent(Intent.ACTION_SEND);
sendIntent.setType("application/octet-stream");
sendIntent.putExtra(Intent.EXTRA_EMAIL,newString[] {"san123@gmail.com"});
sendIntent.putExtra(Intent.EXTRA_SUBJECT, "Test");
sendIntent.putExtra(Intent.EXTRA_TEXT, "Hy Testing");
sendIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse("file://" + file.getAbsolutePath()));

startActivity(Intent.createChooser(sendIntent, "Send Mail"));

and also add following permission

<uses-permissionandroid:name="android.permission.INTERNET" /><uses-permissionandroid:name="android.permission.ACCESS_NETWORK_STATE" />

Solution 2:

Try

Intentsend=newIntent(Intent.ACTION_SENDTO);
        StringuriText="mailto:" + Uri.encode("a@b.com") + 
                  "?subject=" + Uri.encode("the subject") + 
                  "&body=" + Uri.encode("the body of the message");
        Uriuri= Uri.parse(uriText);

        send.setData(uri);
        startActivity(Intent.createChooser(send, "Send mail..."));

Add Permission in Manifest for Internet Access.

<uses-permissionandroid:name="android.permission.INTERNET" /><uses-permissionandroid:name="android.permission.ACCESS_NETWORK_STATE" />

Solution 3:

Stringto= toEmail.getText().toString();
Stringsubject= emailSubject.getText().toString();
Stringmessage= emailBody.getText().toString();
Intentemail=newIntent(Intent.ACTION_SEND);
email.putExtra(Intent.EXTRA_EMAIL, newString[] { to });
email.putExtra(Intent.EXTRA_SUBJECT, subject);
email.putExtra(Intent.EXTRA_TEXT, message);
// need this to prompts email client only
email.setType("message/rfc822");
startActivity(Intent.createChooser(email, "Choose an Email client"));

Post a Comment for "Email Not Sending From Android Application"