An email is sent from lets say gg@gg.com with an attachment to 2 email id's .One, my email id and another xx@xx.com I got that email. When i did mail search using java Mail API with email id as search criteria , it is not able to find it though i received that email.But when i forward it to the same email id's search criteria is working fine. Please let me know when email is received for the first time at that point why it is not able to search
Properties properties = System.getProperties();
properties.put("mail.smtp.host", ExchangeProperties.getSmtpHost());
properties.put("mail.pop3.connectiontimeout", String.valueOf(ExchangeProperties.getPop3ConnectionTimeout() * 1000));
properties.put("mail.pop3.timeout", String.valueOf(ExchangeProperties.getPop3Timeout() * 1000));
session = Session.getInstance(properties, null);
session.setDebug(logger.isDebugEnabled());
// Get the store
store = session.getStore("pop3");
store.connect(ExchangeProperties.getSmtpHost(), user, password);
Folder folder = store.getFolder(folderName)
Message[] foundMessages = folder.search(andTerm); //andTerm contains email id
FetchProfile fp = new FetchProfile();
fp.add(FetchProfile.Item.ENVELOPE);
folder.fetch(foundMessages, fp);