Hi all,
I have an Exchange Mailbox with an email alias configured. So, when somebody send a mail to the email alias I should be able to get it with my java code to process it. The problem is the recipient id is allways populated with the root mailbox address and not with the alias previously setup.
Mailbox: testMail@mailserver.com
Aliases: testMail-alias1@mailserver.com, testMail-alias2@mailserver.com
The code to check the received mails is the following:
--------------------Java Code-----------------------
public void checkMailsTest(Store connStore, String mailAddress) throws MessagingException{
Folder folderInbox = connStore.getFolder("INBOX");
folderInbox.open(Folder.READ_WRITE);
Message[] foundMessages = folderInbox.search(new FlagTerm(new Flags(Flags.Flag.SEEN), false));
logger.info("checkMailsTest() unread e-mails found: {}", foundMessages.length);
for (int i = 0; i < foundMessages.length; i++) {
MimeMessage miMsg = (MimeMessage) foundMessages[i];
Enumeration headers = miMsg.getAllHeaders();
while(headers.hasMoreElements()){
Header header = (Header) headers.nextElement();
System.out.println(header.getName() + " : " + header.getValue());
}
}
}
----------------------End Code------------------------
Now, with the following code, I'm reading the messages and getting the header fields. So when I check the CC field is coming with the value of the mailbox name but not with the alias name. Nevertheless, if I check the message details in exchange mail application, the CC value is populated with the alias name (as it should be)
Any idea how can I get the correct CC value?
Thanks a lot in advance
BR
Max