Deepak
Deepak

Reputation: 131

How send a mail over gmail

i am getting data from edit text and try to send it over a gmail id but i am getting this "No apps perform this action" please tell me where i am doing wrong because i am new in android thanks

public void onClick(View v) {
        // TODO Auto-generated method stub
        if(v.getId() == R.id.send)
        {
            String name = objName.getText().toString();
            Intent email = new Intent(Intent.ACTION_SEND);
            email.putExtra(Intent.EXTRA_EMAIL, new String[]{ "[email protected]"});
            email.putExtra(Intent.EXTRA_SUBJECT, name);
            email.setType("message/rfc822");
            startActivity(Intent.createChooser(email, "Send Mail :"));

        }
    }

Upvotes: 0

Views: 94

Answers (2)

Abbyjeet
Abbyjeet

Reputation: 89

If you are using SDK Simulator, then you may not be having GMail app installed on it.

Upvotes: 0

Oli
Oli

Reputation: 3536

Try

public void onClick(View v) {
        // TODO Auto-generated method stub
        if(v.getId() == R.id.send)
        {
            String name = objName.getText().toString();
            Intent email= new Intent(android.content.Intent.ACTION_SEND);
            email.setType("text/plain");
            email.putExtra(Intent.EXTRA_EMAIL, new String[]{ "[email protected]"});
            email.putExtra(Intent.EXTRA_SUBJECT, name);
            startActivity(email);   

        }
    }

Upvotes: 1

Related Questions