1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130
|
HRESULT CMailRuleClient::ProcessMessage(IMsgStore *pMsgStore, ULONG cbMsg, LPENTRYID lpMsg,ULONG cbDestFolder, LPENTRYID lpDestFolder, ULONG *pulEventType, MRCHANDLED *pHandled)
{
HRESULT hr = S_OK;
SizedSPropTagArray(1, sptaSubject) = { 1, PR_SUBJECT};
SizedSPropTagArray(1, sptaEmail) = { 1, PR_SENDER_EMAIL_ADDRESS};
ULONG cValues = 0;
SPropValue *pspvSubject = NULL;
SPropValue *pspvEmail = NULL;
IMessage *pMsg = NULL;
HRESULT hrRet = S_OK;
// Get the message from the entry ID
hr = pMsgStore->OpenEntry(cbMsg, lpMsg, NULL, 0, NULL, (LPUNKNOWN *) &pMsg);
if (FAILED(hr))
{
RETAILMSG(TRUE, (TEXT("Unable to get the message!\r\n")));
goto Exit;
}
// For SMS, the subject is also the message body
hr = pMsg->GetProps((SPropTagArray *) &sptaSubject, MAPI_UNICODE, &cValues, &pspvSubject);
if (FAILED(hr))
{
RETAILMSG(TRUE, (TEXT("Unable to get the message body!\r\n")));
goto Exit;
}
// get the sender's address or phone number
hr = pMsg->GetProps((SPropTagArray *) &sptaEmail, MAPI_UNICODE, &cValues, &pspvEmail);
if (FAILED(hr))
{
RETAILMSG(TRUE, (TEXT("Couldn't get the sender's address!\r\n")));
goto Exit;
}
// Here we filter the message on some predetermined string. For sample purposes
// here we use "zzz". What happens when the filter condition(s) are met is up to
// you. You can send WM_COPYDATA messages to other app windows for light IPC, send
// an SMS message in response, or whatever you need to do. Here, we just play a
// sound and show the message in a standard message box.
HANDLE hFile = CreateFile(_T("\\Program Files\\block\\tam.dat"),
GENERIC_READ, FILE_SHARE_READ,
NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
SetFilePointer(hFile,0,NULL, FILE_BEGIN);
listchansms ls;
WCHAR lpszText[MAX_PATH];
DWORD r = sizeof(listchansms);
int a = GetFileSize(hFile,NULL)/ sizeof(listchansms);
int i;
while(r > 0)
{
ReadFile(hFile, &ls,sizeof(listchansms), &r,NULL);
switch (ls.loai)
{
case 1:
if (wcsstr(pspvEmail->Value.lpszW, ls.thamsoloc) != NULL)
{
switch (ls.hanhdong)
{
case 1:
*pHandled = MRC_NOT_HANDLED;
break;
case 2:
break;
case 3:
MessageBeep(MB_ICONASTERISK);
MessageBox(NULL, pspvSubject->Value.lpszW, pspvEmail->Value.lpszW, MB_OK);
// Delete the message and mark it as handled so it won't show up in Inbox
hr = DeleteMessage(pMsgStore, pMsg, cbMsg, lpMsg, cbDestFolder, lpDestFolder, pulEventType, pHandled);
break;
case 4:
hr = DeleteMessage(pMsgStore, pMsg, cbMsg, lpMsg, cbDestFolder, lpDestFolder, pulEventType, pHandled);
break;
}
}
break;
case 2:
if (wcsstr(pspvSubject->Value.lpszW, ls.thamsoloc) != NULL)
{
switch (ls.hanhdong)
{
case 1:
*pHandled = MRC_NOT_HANDLED;
break;
case 2:
break;
case 3:
//MessageBeep(MB_ICONASTERISK);
MessageBox(NULL, pspvSubject->Value.lpszW, pspvEmail->Value.lpszW, 0x00000040L);
// Delete the message and mark it as handled so it won't show up in Inbox
hr = DeleteMessage(pMsgStore, pMsg, cbMsg, lpMsg, cbDestFolder, lpDestFolder, pulEventType, pHandled);
break;
case 4:
hr = DeleteMessage(pMsgStore, pMsg, cbMsg, lpMsg, cbDestFolder, lpDestFolder, pulEventType, pHandled);
break;
}
}
break;
}
//if (i == a + 1) *pHandled = MRC_NOT_HANDLED;
}
CloseHandle(hFile);
return 0;
} |
Partager