I am looking for a way to copy messages, which have been sent through a SMTP server, to a dedicated folder on an IMAP server.
So far I tried this:
MimeMessage message = new MimeMessage(smtpSession);
// (...) Set up fields subject, to, cc, bcc, etc...
sendMessage(message); // Works!
Folder sourceFolder = message.getFolder(); // Returns null of course :-(
Message messages = new Message;
messages = message;
sourceFolder.copyMessages(messages, destinationFolder); // Nullpointer exception here because message has no parent folder
// (destinationFolder is an IMAP folder on an IMAP server with working connection)
No luck so far because the code above fails due to a nullpointer exception.