OnSendItem problem

  • Thread starter Thread starter dorutzu
  • Start date Start date
D

dorutzu

Hi,

I have the following problem:

In the OnSendItem event handler, I create a new MailItem based on the
parameter I got from the function (I'm working in VC++), I take some
info out of it, and then Release my MailItem. The problem is that
after the e-mail is sent, in the Outbox I have a duplicate of my sent
e-mail. Any idea how to get read of it? (besides moving it to Deleted
folder - that is not acceptable). I have to delete it somehow, but I
don't know where I go wrong here.
I'm using Redemption as well, if the SafeMailItem has something to
help me here...

Thanks in advance,
Doru K.
 
Hi,

As I said, it's written in VC++, so here it goes:

void CMain::OnSendItem(CComPtr<IDispatch> spDisp)
{
HRESULT hr;

USES_CONVERSION;

//create the safe mail object:
CLSID clsid;
ISafeMailItemPtr pSafeMail = NULL;

if ((hr = ::CLSIDFromProgID(L"Redemption.SafeMailItem", &clsid)) !=
NOERROR)
return;

if ((hr = ::CoCreateInstance(clsid, NULL, CLSCTX_INPROC_SERVER,
__uuidof(ISafeMailItem),
(void**)&pSafeMail)) != S_OK)
return;

CComQIPtr<Outlook::_MailItem> spTheMail(spDisp);//I will use this to
move the remaining e-mail to the 'Deleted' folder
if(spTheMail == NULL)
return;

hr = pSafeMail->put_Item(spTheMail);
if(FAILED(hr) || (pSafeMail == NULL))
return;

ISafeRecipientsPtr pSafeRecipients;
hr = pSafeMail->get_Recipients(&pSafeRecipients);
if(FAILED(hr))
return;
if(pSafeRecipients == NULL)
return;

////// Do some stuff here////

if(pSafeMail != NULL)
{
pSafeMail.Release(); delete pSafeMail;
}
//create the redemption cleanup object and clean up after redemption -
for Outlook XP
IMAPIUtilsPtr pMapiUtils = NULL;
if ((hr = ::CLSIDFromProgID(L"Redemption.MAPIUtils", &clsid)) !=
NOERROR)
return;
if ((hr = ::CoCreateInstance(clsid, NULL, CLSCTX_INPROC_SERVER,
__uuidof(IMAPIUtils), (void**)&pMapiUtils)) != S_OK)
return;
if(pMapiUtils != NULL)
{
pMapiUtils->Cleanup();
pMapiUtils.Release(); delete pMapiUtils;
}
//and here I should do something with spTheMail, but I don;t know how
to get read of it...for now I only mark it as unread, and move it to
the Deleted items folder.
}

Any help would be much appreciated. Thanks!

Doru K.
 
I am still not sure what you do in the event handler. Do you delete the
original message and move it to the Deleted Items folder?

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
 
Hi,

Thanks for your answers...I looked more carefuly, and I found the
problem. Thank you, and sorry for the trouble.

Doru
 
Back
Top