Forum Stats

  • 3,740,940 Users
  • 2,248,348 Discussions


Query the value of CC: using Javax.mail (not really working)

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: [email protected]

Aliases: [email protected], [email protected]

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");;

  Message[] foundMessages = FlagTerm(new Flags(Flags.Flag.SEEN), false));"checkMailsTest() unread e-mails found: {}", foundMessages.length);

  for (int i = 0; i < foundMessages.length; i++) {

    MimeMessage miMsg = (MimeMessage) foundMessages[i];

    Enumeration headers = miMsg.getAllHeaders();


      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



Sign In or Register to comment.