#include <stdio.h>
#include <stdlib.h>
#include <windows.h>
#include <Ole2.h>
#include <OleCtl.h>
int main() {
CoInitialize(NULL);
// Step 1: Initialize MAPI
LPMAPISESSION lpSession = NULL;
HRESULT hRes = MAPIInitialize(NULL);
if (hRes != S_OK) {
CoUninitialize();
return 1;
}
// Step 2: Log in to the profile
hRes = MAPILogonEx(0, NULL, NULL, MAPI_EXTENDED | MAPI_LOGON_UI, &lpSession);
if (hRes != S_OK) {
MAPIUninitialize();
CoUninitialize();
return 1;
}
// Step 3: Get the Inbox folder
LPMAPIFOLDER lpInboxFolder = NULL;
hRes = lpSession->OpenMsgStore(NULL, 0, NULL, 0, 0, &lpInboxFolder);
if (hRes != S_OK) {
lpSession->Logoff(0, 0, 0);
MAPIUninitialize();
CoUninitialize();
return 1;
}
// Step 4: Get the table of Outlook items
LPMAPITABLE lpTable = NULL;
hRes = lpInboxFolder->GetContentsTable(0, &lpTable);
if (hRes != S_OK) {
lpInboxFolder->Release();
lpSession->Logoff(0, 0, 0);
MAPIUninitialize();
CoUninitialize();
return 1;
}
// Step 5: Set the property to align items left
SPropTagArray tagArray;
tagArray.cValues = 1;
tagArray.aulPropTag[0] = PR_JUNK_EITS_FLAGS;
SRestriction restriction;
restriction.rt = RES_EXIST;
restriction.res.resExist.ulPropTag = PR_JUNK_EITS_FLAGS;
SPropValue propValue;
propValue.ulPropTag = PR_JUNK_EITS_FLAGS;
propValue.Value.l = JUNK_EITS_JUNK_EIT_ENABLE;
// Step 6: Set the property for each item in the table
hRes = lpTable->SetColumns(&tagArray, 0);
if (hRes == S_OK) {
hRes = lpTable->Restrict(&restriction, 0);
if (hRes == S_OK) {
hRes = lpTable->SetRowProps(1, 1, &propValue, NULL);
}
}
// Step 7: Release resources
lpTable->Release();
lpInboxFolder->Release();
lpSession->Logoff(0, 0, 0);
MAPIUninitialize();
CoUninitialize();
return 0;
}