当前位置: 代码迷 >> Windows Mobile >> MAPI 移动短信到回收站,该怎么解决
  详细解决方案

MAPI 移动短信到回收站,该怎么解决

热度:166   发布时间:2016-04-25 07:58:57.0
MAPI 移动短信到回收站
我现在要做短信过滤的功能,在收到新短信的时候把它移动到回收站。用MAPI怎么写移动短信这段,最好能贴一段Code,谢谢大家~~

------解决方案--------------------
pSubFolder = GetFolder(pMsgStore, PR_CE_IPM_DRAFTS_ENTRYID, &cbDestFolder,&lpDestFolder);
if (pSubFolder)
{
ENTRYLIST lst;
SBinary sbin;
sbin.cb = cbMsg;
sbin.lpb = (LPBYTE)lpMsg;
lst.cValues = 1;
lst.lpbin = &sbin;
if (lpDestFolder)
hr = pFolder-> CopyMessages(&lst, 0, pSubFolder, NULL, NULL, MESSAGE_MOVE);

------解决方案--------------------
我已经试过了,这个可以。

RESULT hr = S_OK;
ENTRYLIST lst;
SBinary sbin;
IMAPIFolder *pFolder = NULL;

// Delete it
hr = pMsgStore-> OpenEntry(cbDestFolder, lpDestFolder, NULL, 0, NULL, (LPUNKNOWN *)&pFolder);
if (FAILED(hr))
{
RETAILMSG(TRUE, (TEXT( "Couldn 't get the folder!\r\n ")));
goto Exit;
}

ULONG ulValues = 0;
LPMAPIFOLDER* pWasteFolder;
LPSPropValue rgprops = NULL;
ULONG rgTags[] = {1, PR_IPM_WASTEBASKET_ENTRYID};

pMsgStore-> GetProps((LPSPropTagArray) rgTags, MAPI_UNICODE, &ulValues, &rgprops);

pMsgStore-> OpenEntry(rgprops[0].Value.bin.cb, (LPENTRYID)rgprops[0].Value.bin.lpb, NULL, MAPI_MODIFY, NULL, (LPUNKNOWN*)&pWasteFolder);
MAPIFreeBuffer(rgprops);

lst.cValues = 1;
sbin.cb = cbMsg;
sbin.lpb = (LPBYTE) lpMsg;
lst.lpbin = &sbin;

hr = pFolder-> CopyMessages(&lst, NULL, pWasteFolder, 0, NULL, MESSAGE_MOVE);

*pulEventType = fnevObjectDeleted;
*pHandled = MRC_HANDLED_DONTCONTINUE;

Exit:
if (pFolder)
{
pFolder-> Release();
}

return hr;