2

I'm been following this link Sending Email in Android using JavaMail API without using the default/built-in app, but it doesn't work for me, that code throw an exception, and if I do a try..catch, it doesn't catch anything. There is anyone that have tried that code and worked for them? Could you upload a working code for test? When I track the code, the error is after the creation of the DataHandler, I don't know why. I Add external libs, mail, activation, additional, and doesn't work, i don't know what is my problem.

titusfx
  • 1,896
  • 27
  • 36
  • in catch add e.printtracktrace()...and which error occure?? – Samir Mangroliya Sep 16 '11 at 12:47
  • in the catch i make Log.e( tag, e.getMessage()); and this dont catch anything, the error where only i see is in the app that say, that Sorry, that application stopped...etc – titusfx Sep 16 '11 at 12:55
  • add your code.........and check on device also........... – Samir Mangroliya Sep 16 '11 at 13:01
  • String Body = "This is the Body of my email"; new DataHandler(new ByteArrayDataSource(body.getBytes(), "text/plain")); send a execption. and my ByteArrayDataSource is like the link the i put... – titusfx Sep 16 '11 at 14:04
  • in that link i see that a lot of peaple says that run ok, i just un source code of somebody its run, where i can see, if the problem consiste i think that i need update somethig... – titusfx Sep 16 '11 at 14:07
  • Are you running this on a phone or on an emulator? – JPM Sep 16 '11 at 20:20
  • on emulator and in the phone... both – titusfx Sep 17 '11 at 22:56

1 Answers1

0

I've found other way to receive emails from gmail or any other email provider.

     Properties props = new Properties();
    //IMAPS protocol
    props.setProperty("mail.store.protocol", "imaps");
    //Set host address
    props.setProperty("mail.imaps.host", "imaps.gmail.com");
    //Set specified port
    props.setProperty("mail.imaps.port", "993");
    //Using SSL
    props.setProperty("mail.imaps.socketFactory.class", "javax.net.ssl.SSLSocketFactory");
    props.setProperty("mail.imaps.socketFactory.fallback", "false");
    Session imapSession = Session.getInstance(props);
    Store store = imapSession.getStore("imaps");
    store.connect("imap.gmail.com", usr, password);
Folder inbox = store.getFolder("Inbox");
inbox.open(Folder.READ_WRITE);
    Message[] msgs =inbox.getMessages()
titusfx
  • 1,896
  • 27
  • 36