When Outlook’s POP3 provider syncs with a POP3 mailbox and the user chooses to leave a copy of the messages on the server, it has to remember which messages it has already downloaded so it doesn’t accidently download the same message twice. It does this by tracking the UIDL of each message it has downloaded in a binary property on a hidden message. This post describes how Outlook locates this binary property. My next post will detail how to parse this property.
SRestriction rgRes[3]; SPropValue rgProps[3]; rgRes[0].rt = RES_AND; rgRes[0].res.resAnd.cRes = 2; rgRes[0].res.resAnd.lpRes = &rgRes[1]; rgRes[1].rt = RES_PROPERTY; rgRes[1].res.resProperty.relop = RELOP_EQ; rgRes[1].res.resProperty.ulPropTag = PR_CONVERSATION_KEY; rgRes[1].res.resProperty.lpProp = &rgProps[0]; rgRes[2].rt = RES_PROPERTY; rgRes[2].res.resProperty.relop = RELOP_EQ; rgRes[2].res.resProperty.ulPropTag = PR_MESSAGE_CLASS; rgRes[2].res.resProperty.lpProp = &rgProps[1]; rgProps[0].ulPropTag = PR_CONVERSATION_KEY; rgProps[0].Value.bin = pVals[iSearchKey].Value.bin; // PR_SEARCH_KEY from the profile rgProps[1].ulPropTag = PR_MESSAGE_CLASS; rgProps[1].Value.LPSZ = (LPTSTR)"IPM.MessageManager";
SRestriction rgRes[3];
SPropValue rgProps[3];
rgRes[0].rt = RES_AND;
rgRes[0].res.resAnd.cRes = 2;
rgRes[0].res.resAnd.lpRes = &rgRes[1];
rgRes[1].rt = RES_PROPERTY;
rgRes[1].res.resProperty.relop = RELOP_EQ;
rgRes[1].res.resProperty.ulPropTag = PR_CONVERSATION_KEY;
rgRes[1].res.resProperty.lpProp = &rgProps[0];
rgRes[2].rt = RES_PROPERTY;
rgRes[2].res.resProperty.relop = RELOP_EQ;
rgRes[2].res.resProperty.ulPropTag = PR_MESSAGE_CLASS;
rgRes[2].res.resProperty.lpProp = &rgProps[1];
rgProps[0].ulPropTag = PR_CONVERSATION_KEY;
rgProps[0].Value.bin = pVals[iSearchKey].Value.bin; // PR_SEARCH_KEY from the profile
rgProps[1].ulPropTag = PR_MESSAGE_CLASS;
rgProps[1].Value.LPSZ = (LPTSTR)"IPM.MessageManager";
rgRes[1].res.resProperty.ulPropTag = rgProps[0].ulPropTag = PR_SEARCH_KEY;
"Outlook Message Manager (%s) (KEY: %s)", PR_PROFILE_NAME, HexFromBin(PR_SEARCH_KEY)
For Outlook 2010 and higher, you can substitute the following for steps 3-6:
CHAR g_szGeneralKey[] = "General Key"; const SBinary g_binGeneralKey = {sizeof(g_szGeneralKey), (LPBYTE)g_szGeneralKey};
CHAR g_szGeneralKey[] = "General Key";
const SBinary g_binGeneralKey = {sizeof(g_szGeneralKey), (LPBYTE)g_szGeneralKey};
Now, use these values for PR_SEARCH_KEY and PR_PROFILE_NAME and run through steps 3-6. If this fails to find a message, fall back to the original steps 3-6.
There may be more than one attachment on the message. Try the following, in order (note again the use of printf style notation)::
PRO_ACCT_MINI_UID is a property you can retrieve via the Account Management API. Here’s the definition:
#define PROP_ACCT_MINI_UID PROP_TAG(PT_DWORD, 0x0003)
The POP3 UIDL data blob is stored in PR_ATTACH_DATA_BIN.
We’ll discuss how to parse this blob in my next post. Stay tuned.
Enjoy!