There is a problem with the receipt of letters from e-mail to Android.

public class pop3 { static String nike; static String mes; public static void Messages() throws Exception { Properties props = new Properties(); String host = "pop.yandex.ru"; String username = "romanzi777@yandex.ru"; String password = "cybercuba"; String provider = "pop3"; Session session = Session.getInstance(props, null); Store store = session.getStore(provider); store.connect(host, username, password); Folder inbox = store.getFolder("INBOX"); if (inbox == null) { Log.e("Mail", "No INBOX"); } inbox.open(Folder.READ_ONLY); Message[] messages = inbox.getMessages(); for (int i = 0; i < messages.length; i++) { Log.e("Mail", "Всего писем:" + messages.length); Log.e("Mail", "Message " + (i + 1)); nike = messages[i].getSubject().toString(); if (nike.contains("FlyNote:")) { nike = nike.substring(0, 7); mes = messages[i].getContent().toString(); } } inbox.close(false); store.close(); } 

When processing this code, the application crashes.

pop3.Messages ();

In the console (on Android) everything works. On Android, the following comes to the log:

09-23 06:40: 23.145: E / AndroidRuntime (324): java.lang.NoClassDefFoundError: javax.mail.Session

At the line:

  Session session = Session.getInstance(props, null); 

What is the problem?

  • 3
    I'm looking at the question and I think) is the password real or something? - rasmisha
  • Please post a normal working code. And then I have a similar problem - Vladimir Oleynikov

2 answers 2

There is an assumption and very persistent that the code uses a class or even a package, which is simply not in the Android SDK.

  • one
    Yes, the Mail API in Android is not. It is recommended to use Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND); - Barmaley

By the way. I have an application compiled for platform 2.2, when launched in AVD Android 2.2 API8 produced a similar error. But since AVD Android 2.3.3 (API10) it worked, and without reassembling the program itself. On a live device with Android 2.2 has not yet verified ...

ps Although it is rather from the category of mysticism. ;) More like a conflict with some components when building, when the Session of the external library overlaps with the Session of something else.