I've recently been working with code that uses Yahoo! Mail Web Services API to interact with Yahoo! Mail. I am trying to search for messages (from a specific sender) using YmwsStub.SearchMessages and keep getting inaccurate results. While testing, there were 6 messages from the given sender in the inbox, but only 3 messages were being returned in the search results. The search was consistent in that it always returned the same subset of emails. I then sent 3 other emails from a different sender account to the yahoo inbox and tried searching for that sender email address. This search would only return 1 of the 3 emails (but always the same email).
I have tried authenticating with both BBAuth and OAuth, and I get the same results each time.
Out of curiosity, I tried the same search using the Yahoo! YQL Console, and all of the messages were returned using that method.
I tried testing again the next morning, and magically everything was returning correctly. I searched the same inbox for the same senders with the same code as the previous day, and everything was coming back correctly this time. I sent more emails from the two sender address, and each search returned all the messages correctly.
Later in the day, I sent a couple more messages to test again and found that 1 of the 3 new messages was not being returned in the search response. (And again, YQL Console was returning it just fine)
Here is the Java code that is making the search request:
@Override
public String[] getMessageIdsFromSender(String folderId, String senderSearchString, int maxResults) throws SessionException {
List<String> mids = new ArrayList<String>();
try {
YmwsStub.SearchMessages39 searchRequest = new YmwsStub.SearchMessages39();
searchRequest.setSearchMessages(new YmwsStub.SearchMessages());
searchRequest.getSearchMessages().setSearch(new YmwsStub.SearchQuery());
searchRequest.getSearchMessages().getSearch().setFrom(senderSearchString);
searchRequest.getSearchMessages().getSearch().setFrommatchmode(YmwsStub.SearchMatchMode.contains);
searchRequest.getSearchMessages().getSearch().setFid(new String[] { folderId });
searchRequest.getSearchMessages().setStartMid(new UnsignedLong(0));
searchRequest.getSearchMessages().setNumMid(new UnsignedLong(maxResults));
YmwsStub.ListMessagesResponse searchResponse = stub.SearchMessages(searchRequest, null).getListMessagesResponse();
if (searchResponse.getMid() != null) {
for (String mid : searchResponse.getMid()) {
mids.add(mid);
}
}
} catch (RemoteException re) {
throwYmailSessionException(re);
}
return (String[]) mids.toArray(new String[mids.size()]);
}
Has anyone else experienced this type of inconsistency with SearchMessages?
Suggestions?
Any help would be greatly appreciated,
Thank You