LoneWolfPR
LoneWolfPR

Reputation: 4090

Android: Send email through basic email app from another application in emulator?

I have a basic handler set up to call the email application in the emulator and send an email. I've set up the email app in the emulator with my info so it's ready to go. However, when I click the button in my app to bring up a compose window I get the prompt that says: "No applications can perform this action"

Is this just something you can't do with the emulator?

private OnClickListener submitBtn = new OnClickListener(){
    public void onClick(View v){
        Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
        String emailTo = "[email protected]";
        String emailSubject = "Subject";
        String emailBody = "Some HTML goes here.";
        emailIntent.setType("text/html");
        emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL,emailTo);
        emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT,emailSubject);
        emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, Html.fromHtml(emailBody));
        startActivity(Intent.createChooser(emailIntent, "Send email in:"));
    }
};

Upvotes: 1

Views: 2082

Answers (3)

Pascal Dimassimo
Pascal Dimassimo

Reputation: 6928

I was able to make it work in the emulator by configuring the basic email app with a valid email address.

Upvotes: 0

Andrew Mackenzie
Andrew Mackenzie

Reputation: 5747

Add

intent.setType( "message/rfc822" );

or

intent.setType( "text/html" );

This will cause Android to show a chooser to the user for all applications that can send these types of messages. The html option may put up non-email apps so I use the rfc822 option.

Upvotes: 1

Adrian Spinei
Adrian Spinei

Reputation: 550

Try a third party app such as K9Mail http://code.google.com/p/k9mail/

The code looks fine, you're hitting some emulator limitations...

Upvotes: 0

Related Questions