Newbie Redemption ISafeMailItemPtr question

G

Gabriel

Hi, back with another probably trivial question. I want to use Redemption to
access the headers of a message in my ATL/COM add-in. I thought that to set
my ISafeMailItemPtr object I just need to do this:

CComPtr<IDispatch> dispItem;

hr = spSelection->Item(nItem,&dispItem);




Redemption::ISafeMailItemPtr redMailPtr;

redMailPtr->put_Item(dispItem);

However Outlook (2003) crashes with an "abnormal program termination" error.
I know dispItem is getting set correctly as I'm using it elsewhere in that
method without issue. Is there something obvious I'm missing here?

Much obliged as always,
 
G

Gabriel

Hi Dmitry,

"redMailPtr->put_Item(dispItem)" causes the crash. I can comment that line
out and the method runs fine. (I'm not actually doing anything with the
object yet.) Just to make sure I didn't botch this up, to use Redemption I'm
just putting this in my StdAfx.h file, mimicking the import lines for the
Outlook/Office object models:

#import "C:\Program Files\Redemption\Redemption.dll" rename_namespace(
"Redemption" ), named_guids

using namespace Redemption;

Is this correct? Let me know if you need more information. Thanks again for
your assistance.

-Gabriel
 
G

Gabriel

Hi again Dmitry,

I thought that's what

Redemption::ISafeMailItemPtr redMailPtr;
redMailPtr->put_Item(dispItem);

did, creating a ISafeMailItemPtr object and passing an item to it. Should I
be creating an ISafeMailItem instead of Ptr?

Thanks again,

-Gabriel
 
D

Dmitry Streblechenko

Of course. You simply declare a variable.
Have you tried redMailPtr.CreateInstance()?

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

Gabriel

Hi Dmitry,

That sorted me out. This is what I ended up doing:

CComVariant headers;

headers.vt = VT_BSTR;



Redemption::ISafeMailItemPtr redMailPtr;

redMailPtr.CreateInstance(__uuidof(Redemption::SafeMailItem));

redMailPtr->put_Item(dispItem);

redMailPtr->get_Fields(0x7D001E, &headers);

One more newbie question just out of curiosity, why is it
"__uuidof(Redemption::SafeMailItem)" rather than
"__uuidof(Redemption::ISafeMailItem)"?

Thanks again for all your help!

-Gabriel
 

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