Newbie Redemption ISafeMailItemPtr question

  • Thread starter R2FicmllbA
  • Start date Views 1,607
Status
Not open for further replies.
R

R2FicmllbA

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,
 
D

Dmitry Streblechenko

Which line of your code causes the crash?

Dmitry Streblechenko (MVP)

-

"Gabriel" <Gabriel> wrote in message

news:7E517503-573E-41DE-88EE-2716769488B6@microsoft.com...
> 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,
>
 
R

R2FicmllbA

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

"Dmitry Streblechenko" wrote:


> Which line of your code causes the crash?

> > Dmitry Streblechenko (MVP)
>

>

>

> -
 
D

Dmitry Streblechenko

How do you create and initialize redMailPtr?

Dmitry Streblechenko (MVP)

-

"Gabriel" <Gabriel> wrote in message

news:6EB14B0E-1502-4627-A2BE-BAE2777D53BD@microsoft.com...
> 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

> "Dmitry Streblechenko" wrote:
>
> > Which line of your code causes the crash?
>

>> > > Dmitry Streblechenko (MVP)
> >

> >

> >

> > -
 
R

R2FicmllbA

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

"Dmitry Streblechenko" wrote:


> How do you create and initialize redMailPtr?

> > Dmitry Streblechenko (MVP)
>

>

>
 
D

Dmitry Streblechenko

Of course. You simply declare a variable.

Have you tried redMailPtr.CreateInstance()?

Dmitry Streblechenko (MVP)

-

"Gabriel" <Gabriel> wrote in message

news:0A2C19B3-1F54-446C-BEF9-ECFF57BAFAF5@microsoft.com...
> 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

> "Dmitry Streblechenko" wrote:
>
> > How do you create and initialize redMailPtr?
>

>> > > Dmitry Streblechenko (MVP)
> >

> >

> >
 
R

R2FicmllbA

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

"Dmitry Streblechenko" wrote:


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

> > Dmitry Streblechenko (MVP)
>

>

>

> -
 
Status
Not open for further replies.
Top