// We found a message url. Determine the message UID from the url.
int messageUID = Integer.parseInt(matcher.group(3));
mLog.debug("Read mime message uid: " + messageUID + " for IMAP url: " + url);
Session session = Session.getInstance(new Properties());
URLName originURLName = new URLName(ImapToolkit.cutMessageIdentifier(
CrawlerToolkit.replaceAuthenticationValuesInURL(url, mAccountPasswordEntry)));
// Replace all %20 with whitespace in folder pathes
String folder = "";
if(originURLName.getFile()!=null){
folder = originURLName.getFile().replaceAll("%20", " ");
}
URLName urlName = new URLName(originURLName.getProtocol(), originURLName.getHost(),
originURLName.getPort(), folder, originURLName.getUsername(), originURLName.getPassword());
IMAPSSLStore imapStore = new IMAPSSLStore(session, urlName);
imapStore.connect();
IMAPFolder currentFolder;
if (urlName.getFile() == null) {
// There is no folder given
currentFolder = (IMAPFolder) imapStore.getDefaultFolder();
} else {
currentFolder = (IMAPFolder) imapStore.getFolder(urlName.getFile());
}
currentFolder.open(Folder.READ_WRITE);
MimeMessage cplMessage = (MimeMessage) currentFolder.getMessageByUID(messageUID);