Message Class and Folder assignment

T

Tom at GSD

Hello,

I am trying to map a message class to a folder. Is there away to
–automatically- have messages get routed to a folder for a specific type of
message class? In other words, I have a message class from a specific
provider (IPM.Note.CustomClass) that is received by Outlook. Instead of the
message ending up in the inbox I would like to automatically end up in
another folder. I know I could capture an event and move the message to that
folder; but is there another way?

Thanks,
Tom –
 
K

Ken Slovak - [MVP - Outlook]

At a level we can access using the Outlook object model everything comes
into Inbox and can be routed from there. I'm not sure if you can intercept
things before Inbox using Extended MAPI but that would be the only
possibility other than Inbox or if you wrote your own store provider (again
Extended MAPI).
 
T

Tom at GSD

Hi Ken,

I have written my own store provider. I originally created a transport that
was working like a charm, but my customer wanted their own store folder. I
then wrote the message store code. I am confused as to how to connect the
actual store (same DLL as transport provider) to a MAPI folder. If you have
any insight as to how to do that I would grealy appreciate it.

Thanks,
Tom -
 
T

Tom at GSD

Hi Ken,

I believe I found the proper procedure for what I am trying to accomplish in
MSDN -- "Opening a Message Store"

Thanks for your help.
 
D

Dmitry Streblechenko

IMsgStore::GetReceiveFolderTable and IMsgStore::GetReceiveFolder were
designed to do exactly that.

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
 
T

Tom at GSD

Thanks Dmitry - that is exactly what I needed to know. By the time I am done
with this provider I think will have experience with almiost every extended
MAPI interface.
 
T

Tom at GSD

Hi Dmitry,

I hope you can take a few minutes and tell me what I am doing wrong - it
would be greatly appreciated.

I have tried a variety of ways to change the message class on my store
folder from Outlook but I run into a road block with every approach. Again my
goal is that all messages from our provider will go to a specified folder in
our msg store. So Essenitally I have the following folder tree of

[-]MyMsgPST
----- Inbox


I am using the below code and every time I try to set the receive (inbox)
folder in my msg store with the new message class I get ACCESS DENIED. Am I
even close to the correct way to change the message class?

Thanks,
Tom



void SetupMessageClassForInbox(CComQIPtr<IMAPISession, &IID_IMAPISession>
spSession)
{
SizedSPropTagArray(2, sptStoreProps) =
{
2,
{
PR_DISPLAY_NAME,
PR_ENTRYID
}
};
try
{
ULONG uFlags = 0;

CComPtr<IMAPITable> spTable;
spSession->GetMsgStoresTable(0, &spTable);
if(spTable != NULL)
{

if(SUCCEEDED(spTable->SetColumns((LPSPropTagArray)&sptStoreProps, 0)))
{
LPSRowSet pProviderRows;
HRESULT hResult = HrQueryAllRows(spTable,
(SPropTagArray*)&sptStoreProps,
NULL,
NULL,
0,
&pProviderRows);

if(SUCCEEDED(hResult))
{
BOOL bFound = FALSE;
for(int nRecp = 0; nRecp < pProviderRows->cRows; nRecp++)
{
TString s = pProviderRows->aRow[nRecp].lpProps[0].Value.lpszW;
if(s.find(_T("MyMsgPST")) != TString::npos)
{
CComPtr<IMsgStore> spStore;
HRESULT hr = spSession->OpenMsgStore(0,
pProviderRows->aRow[nRecp].lpProps[1].Value.bin.cb,
(LPENTRYID)pProviderRows->aRow[nRecp].lpProps[1].Value.bin.lpb,
NULL,
0,
&spStore);
if(SUCCEEDED(hr) && spStore)
{
SPropValue* pPropEID = NULL;
hr = HrGetOneProp(spStore, PR_IPM_SUBTREE_ENTRYID, &pPropEID);
if(SUCCEEDED(hr))
{
ULONG ulObjType = 0;
CComPtr<IMAPIFolder> spFolder;
CComPtr<IMAPIFolder> spParentFolder;


hr = spStore->OpenEntry(
pPropEID->Value.bin.cb,
(LPENTRYID)pPropEID->Value.bin.lpb,
NULL, uFlags, &ulObjType,
(LPUNKNOWN*)&spParentFolder);

if(SUCCEEDED(hr))
{
CComPtr<IMAPITable> spTblHier;

hr = spParentFolder->GetHierarchyTable(uFlags, &spTblHier);
if(SUCCEEDED(hr))
{
LPSRowSet pRowSet = NULL;

SizedSPropTagArray(4, sptFolderProps) =
{
4,
{
PR_ENTRYID,
PR_DISPLAY_NAME,
PR_SUBFOLDERS,
PR_CONTAINER_CLASS
}
};



hr = HrQueryAllRows(spTblHier,
(LPSPropTagArray)&sptFolderProps,
NULL, NULL, 0, &pRowSet);

for(int ind = 0; ind < pRowSet->cRows; ind++)
{
TString strCurrentFolder =
pRowSet->aRow[ind].lpProps[1].Value.lpszW;
if(strCurrentFolder.find("Inbox") != TString::npos)
{
hr = spStore->SetReceiveFolder(
MESSAGE_CLASS, 0,
pRowSet->aRow[ind].lpProps[0].Value.bin.cb,
(LPENTRYID)pRowSet->aRow[ind].lpProps[0].Value.bin.lpb);
return;

}

}
}
}
}
}

break;
}
pProviderRows->aRow[nRecp].lpProps[1].Value;
ATLTRACE(_T("We are here\n"));
}

FreeProws(pProviderRows);
}
}
}
}
catch(...)
{
}
}
 
T

Tom at GSD

Hi Dmitry,

Never mind my last message - I found my bug which not providing the proper
access parameters.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top