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. can i filter some apps from Intent.createChooser?

Hi there,

i am looking to access some chosen native apps available in my phone.

i used the code below but it display some other Apps also which i dont
want.
 intent.setType("text/plain");

                 intent.putExtra(Intent.EXTRA_SUBJECT, subject);
                 intent.putExtra(Intent.EXTRA_TEXT, text);
                 startActivity(Intent.createChooser(intent,
getString(R.string.share_prompt)));


i need to know if i can filter some apps in createChooser like just
facebook, google mail and mail?

Thanks

-- 

2. best place to host apps that target indian market.

Hello,

        Since the market is not open to India for paid apps - What will be a
good server/store to host paid apps that target indian audiences?

Many Thanks,
Vikrant

-- 

3. gps and wifi

4. ACTION_VIEW exception

5. 1-star Market weirdness

6. Build with SDK tool rev 7, gives error: if doesn't support the nested "istrue" element

7. overriding Home button