posted 7 years ago
Hi,
I have a issue while sending the mail through android.
I am trying to send the mail at that time it shows no application can perform this action
see my code as belows :
public void sendEmail(Context context,String subject,String body)
{
final Intent emailIntent = new Intent(Intent.ACTION_SENDTO);
String mailId="abc@gmail.com";
emailIntent.setType("text/plain");
emailIntent.putExtra(Intent.EXTRA_EMAIL,new String[]{mailId});
emailIntent.putExtra(Intent.EXTRA_SUBJECT, subject);
emailIntent.putExtra(Intent.EXTRA_TEXT,body);
context.startActivity(Intent.createChooser(emailIntent, "Send Mail..."));
}
please reply me .
thanks in advanced .
I have a issue while sending the mail through android.
I am trying to send the mail at that time it shows no application can perform this action
see my code as belows :
public void sendEmail(Context context,String subject,String body)
{
final Intent emailIntent = new Intent(Intent.ACTION_SENDTO);
String mailId="abc@gmail.com";
emailIntent.setType("text/plain");
emailIntent.putExtra(Intent.EXTRA_EMAIL,new String[]{mailId});
emailIntent.putExtra(Intent.EXTRA_SUBJECT, subject);
emailIntent.putExtra(Intent.EXTRA_TEXT,body);
context.startActivity(Intent.createChooser(emailIntent, "Send Mail..."));
}
please reply me .
thanks in advanced .

Java Developer
Vijay Nimkarde
Ranch Hand
Posts: 50
posted 7 years ago
@ Ulf Dittmer
thanks for reply.
I have made this change but still the problem remains the same.
I have tested on device also. Not getting the solution.
can we send mails through Java Api . or any other ways that should work in android?
thanks for reply.
I have made this change but still the problem remains the same.
I have tested on device also. Not getting the solution.
can we send mails through Java Api . or any other ways that should work in android?
Java Developer
posted 7 years ago
Yes we can use java mail API to send and retrieve mails.
It will work fine.
Vijay Nimkarde wrote:can we send mails through Java Api .
Yes we can use java mail API to send and retrieve mails.
It will work fine.
Ulf Dittmer
Rancher
Posts: 42975
76
posted 7 years ago
It won't work on the emulator unless you install an application that can handle email; by default no such app is installed. This should help: http://www.androidguys.com/2008/12/12/its-in-the-mail/
Not using standard JavaMail, it won't. An Android-compatible version is required: http://code.google.com/p/javamail-android/
Vijay Nimkarde wrote:I have tested on device also.
It won't work on the emulator unless you install an application that can handle email; by default no such app is installed. This should help: http://www.androidguys.com/2008/12/12/its-in-the-mail/
Hardik Trivedi wrote:Yes we can use java mail API to send and retrieve mails. It will work fine.
Not using standard JavaMail, it won't. An Android-compatible version is required: http://code.google.com/p/javamail-android/
Vijay Nimkarde
Ranch Hand
Posts: 50
posted 7 years ago
@ Ulf Dittmer , Hardik Trivedi
See now I used the following code
--------------------
public void sendEmail(Context context,String subject,String body)
{
final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
emailIntent.setType("text/plain");
String mailId="abc.gmail.com";
emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, new String[]{mailId});
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, subject);
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT,body);
try{
context.startActivity(Intent.createChooser(emailIntent, "Send Mail..."));
finish();
}catch (android.content.ActivityNotFoundException ex) {
Log.v("BBUtils", "Exception while sending email. "+ex);
}
}
-------------------
called text as
String mySubject="Testmail";
String myBodyText="This is simple test body";
sendEmail(ContactUs.this, mySubject, myBodyText);
and i will see the output as in attachments
in that i got the subject whatever i passed but I don't get the email Id Prepopulated as body to whom i am sending the mail.
See the Attachments
See now I used the following code
--------------------
public void sendEmail(Context context,String subject,String body)
{
final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
emailIntent.setType("text/plain");
String mailId="abc.gmail.com";
emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, new String[]{mailId});
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, subject);
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT,body);
try{
context.startActivity(Intent.createChooser(emailIntent, "Send Mail..."));
finish();
}catch (android.content.ActivityNotFoundException ex) {
Log.v("BBUtils", "Exception while sending email. "+ex);
}
}
-------------------
called text as
String mySubject="Testmail";
String myBodyText="This is simple test body";
sendEmail(ContactUs.this, mySubject, myBodyText);
and i will see the output as in attachments
in that i got the subject whatever i passed but I don't get the email Id Prepopulated as body to whom i am sending the mail.
See the Attachments
Java Developer
Vijay Nimkarde
Ranch Hand
Posts: 50
posted 7 years ago
Issue Resolved
I found some where on the Net
see the code
String mailId=(String)ContactUs.this.getString(R.string.contactus8);
Intent emailIntent = new Intent(Intent.ACTION_SENDTO, Uri.fromParts(
"mailto",mailId, null));
//emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, new String[]{mailId});
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, subject);
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT,body);
startActivity(emailIntent);
In this the mail id is getting prepopulated in to the To field .
Still thanks all that replies me
I found some where on the Net
see the code
String mailId=(String)ContactUs.this.getString(R.string.contactus8);
Intent emailIntent = new Intent(Intent.ACTION_SENDTO, Uri.fromParts(
"mailto",mailId, null));
//emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, new String[]{mailId});
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, subject);
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT,body);
startActivity(emailIntent);
In this the mail id is getting prepopulated in to the To field .

Still thanks all that replies me
Java Developer
posted 6 years ago
Hi Prasildas,
If you want to send an E-mail from your Emulator, you first need to configure your E-mail on the Emulator, that is, sign in to any of your mail accounts using the emulator, and then remain signed in.
Then, launch your application in the emulator, and the app will open up the E-mail compose window!
Cheers!!
If you want to send an E-mail from your Emulator, you first need to configure your E-mail on the Emulator, that is, sign in to any of your mail accounts using the emulator, and then remain signed in.
Then, launch your application in the emulator, and the app will open up the E-mail compose window!
Cheers!!

It is sorta covered in the JavaRanch Style Guide. |