IntelliJ Java IDE
The moose likes Android and the fly likes issue: no application can perform this action , when send mail Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Mobile » Android
Reply Bookmark "issue: no application can perform this action , when send mail" Watch "issue: no application can perform this action , when send mail" New topic
Author

issue: no application can perform this action , when send mail

Vijay Nimkarde
Ranch Hand

Joined: Oct 16, 2008
Posts: 50
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 .

Java Developer
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 32768
The intent type should be "message/rfc822".


Android appsImageJ pluginsJava web charts
Vijay Nimkarde
Ranch Hand

Joined: Oct 16, 2008
Posts: 50
@ 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?
Hardik Trivedi
Ranch Hand

Joined: Jan 30, 2010
Posts: 252
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
Marshal

Joined: Mar 22, 2005
Posts: 32768
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

Joined: Oct 16, 2008
Posts: 50
@ 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
[Thumb - email through android.png]
 Filename email through android.png [Disk] Download
 Description email sending through android snap
 Filesize 719 Kbytes
 Downloaded:  99 time(s)

Vijay Nimkarde
Ranch Hand

Joined: Oct 16, 2008
Posts: 50
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
Prasildas Prabhadas
Greenhorn

Joined: Jan 31, 2011
Posts: 3
HI,
I was also in the same situation as of Vijay Nimkarde , even after trying the last solution as posted by Vijay Nimkarde I am getting the same error as before, I could't find any changes even after making those changes
Vm Gv
Greenhorn

Joined: Dec 13, 2011
Posts: 1
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!!
 
 
subject: issue: no application can perform this action , when send mail
 
Threads others viewed
Attaching file which is stored in to the application's directory
Any Api by which i can send the message to differnet mailid
Can we attach multiple email addresses through spring email
Using JMX for mail checking and doing an action
Java Mail Listener
IntelliJ Java IDE