Article ID: 177210
Article Last Modified on 7/1/2004
// lpActs should defined before the main function.
static LPACTIONS lpActs = NULL;
HRESULT hr = NULL;
hr = CreateAction()
HRESULT CreateAction(void)
{
HRESULT hr = NULL;
LPSTR lpszAction = NULL;
hr = MAPIAllocateBuffer(sizeof(ACTIONS), (void**)&lpActs);
if (FAILED(hr) || lpActs == 0)
{
MessageBox(NULL,
"MAPIAllocateBuffer() for lpActs failed.",NULL,MB_OK);
return 1;
}
memset(lpActs, 0, sizeof(ACTIONS));
lpActs->ulVersion = EDK_RULES_VERSION;
lpActs->cActions = 1;
lpActs->lpAction = 0;
hr = MAPIAllocateMore(sizeof(ACTION), lpActs,
(LPVOID*)&lpActs->lpAction);
if (FAILED(hr) || lpActs->lpAction == 0)
{
MessageBox(NULL,
"MAPIAllocateBuffer() for lpAct failed.",NULL,MB_OK);
return 1;
}
memset(lpActs->lpAction, 0, sizeof(ACTION));
/*
// Example of Reply string.
hr = MAPIAllocateBuffer(sizeof("Reply \"Reply Text\""),
(void**) &lpszAction);
// Example of Forward string.
hr = MAPIAllocateBuffer(sizeof("Forward \"<User Name>\""),
(void**) &lpszAction);
*/
// Example of Move String.
hr = MAPIAllocateBuffer(sizeof("Move Mailbox - <User Name>
\\Top of Information Store\\Deleted Items"),
(void**) &lpszAction);
if (FAILED(hr))
{
MessageBox(NULL,"Memory Allocation Failed",NULL,MB_OK);
return 1;
}
// Reply:
//wsprintf(lpszAction,"Reply \"Reply Text\"");
// Forward:
//wsprintf(lpszAction,"Forward \"<User Name>\"");
// Move:
wsprintf(lpszAction,"Move Mailbox - <User Name>
\\Top of Information Store\\Deleted Items");
hr = HrStringToAction(lpSession, lpFolder, lpszAction, lpActs,
&lpActs->lpAction[lpActs->cActions-1]);
if (FAILED(hr))
{
MessageBox(NULL,"Action Failed",NULL,MB_OK);
return 1;
}
return 0;
}
In order to use this code, the following libraries and headers are
required:
Keywords: kbhowto kbcode KB177210