You never save the message
--
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
-
"ryotyankou via OfficeKB.com" u48591@uwe wrote in message
news:9121d684e7a85@uwe...
Not NewMailEx(BSTR xxx), what i processed is Outlook::ItemsEvents
OnItemAdd
(LPDISPATCH).
With the income MailItem, How to add some other recipients to it? I tried
the
following code, but couldn't work:
IUnknownPtr pUnkSession = MailItem-GetSession()-GetMAPIOBJECT();
if(pUnkSession == NULL)
return E_FAIL;
IUnknownPtr pUnkMsg = MailItem-GetMAPIOBJECT();
if(pUnkMsg == NULL)
return E_FAIL;
IMAPISession * pSession;
if(FAILED(pUnkSession-QueryInterface(IID_IMAPISession,
(void**)&pSession)))
{
return E_FAIL;
}
IMessage *pMessage = NULL;
if(FAILED(pUnkMsg-QueryInterface(IID_IMessage, (void**)&pMessage)))
{
pSession-Release();
return E_FAIL;
}
//test only
int nBufSize = CbNewADRLIST(1);
LPADRLIST pAddressList=NULL;
MAPIAllocateBuffer(nBufSize,(LPVOID FAR*)&pAddressList);
memset(pAddressList,0,nBufSize);
const int nProperties=2;
pAddressList-cEntries=1;
pAddressList-aEntries[0].ulReserved1=0;
pAddressList-aEntries[0].cValues=nProperties;
MAPIAllocateBuffer(sizeof(SPropValue)*nProperties, (LPVOID
FAR*)&pAddressList-
aEntries[0].rgPropVals);
memset(pAddressList-aEntries[0].rgPropVals, 0, sizeof(SPropValue)
*nProperties);
pAddressList-aEntries[0].rgPropVals[0].ulPropTag=PR_RECIPIENT_TYPE;
pAddressList-aEntries[0].rgPropVals[0].Value.ul=MAPI_TO;
CString ");
pAddressList-aEntries[0].rgPropVals[1].ulPropTag=PR_DISPLAY_NAME;
pAddressList-aEntries[0].rgPropVals[1].Value.lpszA=(LPSTR)temp.GetString();
// IAddrBook * pAddrBook = NULL;
// if(FAILED(pSession-OpenAddressBook(0, NULL, AB_NO_DIALOG,
&pAddrBook)))
// {
// pSession-Release();
// pMessage-Release();
// FreePadrlist(pAddressList);
// return E_FAIL;
// }
// if(FAILED(pAddrBook-ResolveName(0, cm_nMAPICode, NULL, pAddressList)))
// {
// pSession-Release();
// pMessage-Release();
// FreePadrlist(pAddressList);
// pAddrBook-Release();
// return E_FAIL;
// }
if(FAILED(pMessage-ModifyRecipients(MODRECIP_ADD, pAddressList)))
{
pSession-Release();
pMessage-Release();
FreePadrlist(pAddressList);
// pAddrBook-Release();
return E_FAIL;
}
FreePadrlist(pAddressList);
pMessage-Release();
// pAddrBook-Release();
pSession-Release();
Dmitry Streblechenko wrote:
PR_DISPLAY_TO is not settable.
NewMail event (unlike NewMailEx) does not pass the new message as a
parameter. How do you retrieve the new message?
Do you save the message?
My is ATL/VC2005. OnNewEmail to dispatch the event.
While OnNewEmail function were invoked, I tried the two methods:
[quoted text clipped - 3 lines]
were changed.
What should i do then?
--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...ddins/200902/1