sending and receiving emails from gmail with sdk android
-
21-01-2021 - |
Вопрос
I see Sending Email in Android using JavaMail API without using the default/built-in app, but doesn't work for me, giveme a exception, and if i make try..catch doesnt catch anything, please some body can give me a link to some source code of this exactly code or link? When i track the code the error is after i create DataHandler, i dont know why, I Add external libs, mail, activation, additional, and does work, i dont know what is my problem. Thank a lot!
Решение
i find other way to receive email from gmail or other email.
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()
Не связан с StackOverflow