Sending Email from Android application

by Swathi » Wed, 13 May 2009 03:28:18 GMT


Sponsored Links
 I have tried to send email from myapplication in emulator , with
following code.

Intent sendIntent = new Intent(Intent.ACTION_SEND);
sendIntent.putExtra(Intent.EXTRA_EMAIL, mailto);
sendIntent.putExtra(Intent.EXTRA_SUBJECT,
subject.getText().toString());
sendIntent.putExtra(Intent.EXTRA_TEXT,
body.getText().toString());
sendIntent.setType("text/plain");

startActivity(Intent.createChooser(sendIntent, "MySendMail"));


But i got an error "No applications can perform this action".

I tried by configuring Gmail in emulator, with the following code

        boolean debug = false;
        //Set the host smtp address
        Properties props = new Properties();
        props.setProperty("mail.transport.protocol", "smtp");
        props.setProperty("mail.host", "smtp.gmail.com");
        props.put("mail.smtp.auth", "true");
        props.put("mail.smtp.port", "465");
        props.put("mail.smtp.socketFactory.port", "465");
        props.put("mail.smtp.socketFactory.class",
                             "javax.net.ssl.SSLSocketFactory");
        props.put("mail.smtp.socketFactory.fallback", "false");
        props.setProperty("mail.smtp.quitwait", "false");
        Session session = Session.getDefaultInstance(props, this);
        session.setDebug(debug);
       try
       {
        // create a message
        Message msg = new MimeMessage(session);
        // set the from and to address
        InternetAddress addressFrom = new InternetAddress(from);
        msg.setFrom(addressFrom);
        InternetAddress[] addressTo =
                        new InternetAddress[recipients.length];
        for (int i = 0; i < recipients.length; i++) {
            addressTo[i] = new InternetAddress(recipients[i]);
        }
        msg.setRecipients(Message.RecipientType.TO, addressTo);
        // Setting the Subject and Content Type
        msg.setSubject(subject);
        msg.setContent(message, "text/html");
        Transport.send(msg);
       }
       catch (Exception e) {
                // TODO: handle exception
           System.out.println("Exception in Message"+e.getMessage());
        }
    }


But i got an error but i got an error
"java.lang.verifyError:javax.mail.internet.Mimemessage."

Can anybody help me?

--~--~---------~--~----~------------~-------~--~----~



Sending Email from Android application

by doubleminus » Wed, 24 Jun 2009 13:12:25 GMT


 Swathi,

Did you ever figure this one out??

Thanks,
double



--~--~---------~--~----~------------~-------~--~----~


Sponsored Links


Sending Email from Android application

by Peli » Wed, 24 Jun 2009 21:16:02 GMT


 You can find the correct MIME type to send a text message here:
 http://www.openintents.org/en/node/121 
(scroll down for the sample code)

Peli
www.openintents.org




--~--~---------~--~----~------------~-------~--~----~



Other Threads

1. To delete a file in the SD card, but what to do?

File f = new File(filePath);
f.delete();

BR,
Adrian Vintu

http://adrianvintu.com






> 

2. how to use a Cancel button to clear data in an edittext

EditText editText = (EditText) findViewById(R.id.EditText01);
editText.setText("");

BR,
Adrian Vintu

http://adrianvintu.com




> 

3. Game Developers: Some general questions about high scores, achievements, multi player support and in game ads.

4. Upgrade Spica to 2.1

5. Nexus One won't debug in Ubuntu 9.10

6. Any androiders in Central Florid

7. Zooming into Gallery and Scrolling