how to change email address in outlook2003

H

how_fly

hi,

i want to change email address in outlook2003 when the user submit the
message. i use IExchExtMessageEvents::OnCheckNames(IExchExtCallback
*lpExchangeCallback) to change email-address. my code is following.

And i see the email-address have changed on debugging. but at last,
outlook2003 still send message using the old email-address, and abandon my
changed email-adddress, why???

who will give me some suggestions?? or is there any other ways to changed
email address??

thanks a lot.
my email is: (e-mail address removed)

//in VC6, winxp2, outlook2003
class mymail : public IExchExt, public IExchExtMessageEvents
{...};

STDMETHODIMP mymail::OnCheckNames(IExchExtCallback *lpExchangeCallback)
{
HRESULT hRet = S_OK;
LPMESSAGE lpMessage = NULL;
LPMDB lpMdb = NULL;
LPADRLIST pRecipentRows = NULL;
lpExchangeCallback->GetRecipients(&pRecipentRows);
if( pRecipentRows->cEntries == 0 )
return S_FALSE;
for(unsigned long n = 0; n < pRecipentRows->cEntries; n++ )
{
for(unsigned long i = 0; i < pRecipentRows->aEntries[n].cValues ; i++)
{
ULONG ulTag = pRecipentRows->aEntries[n].rgPropVals.ulPropTag;
if( PR_EMAIL_ADDRESS == ulTag || PR_DISPLAY_NAME == ulTag)
{
// i get the current email address correctly, such as
"(e-mail address removed)"
LPSTR pNow = pRecipentRows->aEntries[n].rgPropVals.Value.lpszA;

// i want to change email address to "(e-mail address removed)"
char* p = "(e-mail address removed)";
char* pNewContact = NULL;
MAPIAllocateBuffer(strlen(p)+1, (LPVOID FAR *)&pNewContact);
strcpy((char*)p, (const char*)pNewContact);
pRecipentRows->aEntries[n].rgPropVals.Value.lpszA = pNewContact;
}
}
}
hRet = lpExchangeCallback->SetRecipients(pRecipentRows); //is S_OK
return S_FALSE;
}
 

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