Please forgive the cross-posting.

I am just trying to create an _MailItemPtr,
which is built from a _com_ptr_t,
given an instance of its underlying raw interface, IMessage.

Why won't this compile?
IMessage* pEmbeddedMsg = ...; // get valid IMessage*
_MailItemPtr pMailItem;
pMailItem.Attach (pEmbeddedMsg);

I get:

"error C2664: 'void
_com_ptr_t<_IIID>::Attach(_com_ptr_t<_IIID>::Interface *) throw()' :
cannot convert parameter 1 from 'IMessage *' to
'_com_ptr_t<_IIID>::Interface *'
with
[
_IIID=_com_IIID<_MailItem,&
_GUID_00063034_0000_0000_c000_000000000046>
]
and
[
_IIID=_com_IIID<_MailItem,&
_GUID_00063034_0000_0000_c000_000000000046>
]"

Do I have to put some wrapper glue around my raw interface pointer?

Thanks very much, Mike

Re: Create _MailItemPtr from IMessage* ? by Brian

Brian
Tue Apr 19 23:36:37 CDT 2005

I'm not familiar with these interfaces, but clearly _MailItemPtr is a smart
pointer for the _MailItem interface, not the IMessage interface.

Does this make sense?

Brian

"MikeJohnson" <mikejohnson@volcanomail.com> wrote in message
news:1113964957.792960.100020@o13g2000cwo.googlegroups.com...
> Please forgive the cross-posting.
>
> I am just trying to create an _MailItemPtr,
> which is built from a _com_ptr_t,
> given an instance of its underlying raw interface, IMessage.
>
> Why won't this compile?
> IMessage* pEmbeddedMsg = ...; // get valid IMessage*
> _MailItemPtr pMailItem;
> pMailItem.Attach (pEmbeddedMsg);
>
> I get:
>
> "error C2664: 'void
> _com_ptr_t<_IIID>::Attach(_com_ptr_t<_IIID>::Interface *) throw()' :
> cannot convert parameter 1 from 'IMessage *' to
> '_com_ptr_t<_IIID>::Interface *'
> with
> [
> _IIID=_com_IIID<_MailItem,&
> _GUID_00063034_0000_0000_c000_000000000046>
> ]
> and
> [
> _IIID=_com_IIID<_MailItem,&
> _GUID_00063034_0000_0000_c000_000000000046>
> ]"
>
> Do I have to put some wrapper glue around my raw interface pointer?
>
> Thanks very much, Mike
>



Re: Create _MailItemPtr from IMessage* ? by Dan

Dan
Wed Apr 20 10:30:49 CDT 2005

"MikeJohnson" <mikejohnson@volcanomail.com> wrote in
news:1113964957.792960.100020@o13g2000cwo.googlegroups.com:
> I am just trying to create an _MailItemPtr,
> which is built from a _com_ptr_t,
> given an instance of its underlying raw interface, IMessage.
>
> Why won't this compile?
> IMessage* pEmbeddedMsg = ...; // get valid IMessage*
> _MailItemPtr pMailItem;
> pMailItem.Attach (pEmbeddedMsg);

Because MailItemPtr isn't a wrapper for IMessage, at least not as far
as the code's concerned. They both point at the same thing somewhere on
the Exchange Server, but they're different interfaces at this end --
MailItemPtr is a wrapper for an OOM object, IMessage is a raw Extended
MAPI pointer.

The only (easy) conversion of this type that you can do is with
CDO1.21, where some objects have a MAPIOBJECT member that lets you go
from the CDO object to an ExMAPI object, but even that one is read-only.

You'll need to pull the ENTRYID out of your IMessage and then pass that
to the appropriate OOM method to get a MailItemPtr.

-- dan



Re: Create _MailItemPtr from IMessage* ? by MikeJohnson

MikeJohnson
Wed Apr 20 21:23:21 CDT 2005

Thanks very much Brian and Dan for your replies.

I assumed the object underlying a _MailItemPtr is an IMessage*.
Untrue- it is an _MailItem.
I think that in some cases there is not a one-to-one correspondence
between
the OOM interface names and the Extended MAPI names. For example:
// Fetch the IAttach interface from the AttachmentPtr object.
CComQIPtr <IAttach, &IID_IAttachment> pAttach =
pAttachment->MAPIOBJECT;

Dan was on the right track with using the ENTRYID to build a
_MailItemPtr.

For anyone interested in building a _MailItemPtr from a raw IMessage*,
it is explained in Q304894, which I couldn't find on the MSDN website,
but was on the MSDN CD-ROM...

Note that in my particular case it is moot, as apparently embedded
messages
do not have their own ENTRYID, but share that of their parent message!

So my code will not treat an embedded message as a standalone message
(as I have no way to fabricate a new _MailItemPtr with a unique
ENTRYID),
but rather I will just pluck out the attachments from the embedded
message.

I wonder how much unique message body content I will bypassing if I
take this course,
or if embedded messages have little unique content of their own?

Thanks,
-Mike


Re: Create _MailItemPtr from IMessage* ? by MikeJohnson

MikeJohnson
Wed Apr 20 21:26:21 CDT 2005

Thanks very much Brian and Dan for your replies.


I assumed the object underlying a _MailItemPtr is an IMessage*.
Untrue- it is an _MailItem.
I think that in some cases there is not a one-to-one correspondence
between
the OOM interface names and the Extended MAPI names. For example:
// Fetch the IAttach interface from the AttachmentPtr
object.
CComQIPtr <IAttach, &IID_IAttachment> pAttach =
pAttachment->MAPIOBJECT;


Dan was on the right track with using the ENTRYID to build a
_MailItemPtr.


For anyone interested in building a _MailItemPtr from a raw IMessage*,
it is explained in Q304894, which I couldn't find on the MSDN website,
but was on the MSDN CD-ROM...


Note that in my particular case it is moot, as apparently embedded
messages
do not have their own ENTRYID, but share that of their parent message!


So my code will not treat an embedded message as a standalone message
(as I have no way to fabricate a new _MailItemPtr with a unique
ENTRYID),
but rather I will just pluck out the attachments from the embedded
message.


I wonder how much unique message body content I will bypassing if I
take this course,
or if embedded messages have little unique content of their own?


Thanks,
-Mike


Re: Create _MailItemPtr from IMessage* ? by MikeJohnson

MikeJohnson
Wed Apr 20 21:27:07 CDT 2005

Thanks very much Brian and Dan for your replies.


I assumed the object underlying a _MailItemPtr is an IMessage*.
Untrue- it is an _MailItem.
I think that in some cases there is not a one-to-one correspondence
between
the OOM interface names and the Extended MAPI names. For example:
// Fetch the IAttach interface from the AttachmentPtr
object.
CComQIPtr <IAttach, &IID_IAttachment> pAttach =
pAttachment->MAPIOBJECT;


Dan was on the right track with using the ENTRYID to build a
_MailItemPtr.


For anyone interested in building a _MailItemPtr from a raw IMessage*,
it is explained in Q304894, which I couldn't find on the MSDN website,
but was on the MSDN CD-ROM...


Note that in my particular case it is moot, as apparently embedded
messages
do not have their own ENTRYID, but share that of their parent message!


So my code will not treat an embedded message as a standalone message
(as I have no way to fabricate a new _MailItemPtr with a unique
ENTRYID),
but rather I will just pluck out the attachments from the embedded
message.


I wonder how much unique message body content I will bypassing if I
take this course,
or if embedded messages have little unique content of their own?


Thanks,
-Mike