public String getAuthorizationCode(String account) throws Exception {
Message email = getMessagesBySubject("Email Subject "+ account, true, 5)[0];
BufferedReader reader = new BufferedReader(new InputStreamReader(email.getInputStream()));
String line;
String prefix = "userId:";
while ((line = reader.readLine()) != null) {
if(line.startsWith(prefix)) {
return line.substring(line.indexOf(":") + 1);
}
}
return null;
}
// publi c Message [] getMessagesBySubject (строковая тема, логическое значение unreadOnly, int maxToSearch) выдает исключение {индексы карт = getStartAndEndIndices (maxToSearch);
Message messages[] = folder.search(
new SubjectTerm(subject),
folder.getMessages(indices.get("startIndex"), indices.get("endIndex")));
if(unreadOnly){
List<Message> unreadMessages = new ArrayList<Message>();
for (Message message : messages) {
if(isMessageUnread(message)) {
unreadMessages.add(message);
}
}
messages = unreadMessages.toArray(new Message[]{});
}
return messages;
}