CDO programming - CDO::Message

S

Semut

How do I attach the MAPI mail item to CDO Message object?
The MAPI mail item do not has the EntryID yet cause it has not been saved
but I have the IDispatch/Instance of Object which I obtain in the
NewInspector event handler. Any functions by CDO Message to attach to the
MAPI mail item instance/IDispatch in C++ I obtained?

Any code examples or link would be appreciated?

thank you.
 
D

Dmitry Streblechenko \(MVP\)

You will not be able to open an Outlook message that hasn't been saved yet
using CDO. You can use MailItem.MAPIOBJECT property (which evaluates to
IMessage in Extended MAPI and can be used from Extended MAPI or Redemption),
but that won't help you either - until the message is saved, Outlook will
not populate the underlying IMessage with the data; the latest changes only
exist in memory and can only be accessed using Outlook Object Model.

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

Semut

I only need to add additional field to the new message through CDO or any
means (Redemption or Extended MAPI if possible) when I obtain the item
through NewInspector and not viewing the latest changes cause I only
interested in new item and not existing one. I can get the MAPIOBJECT from
the IDispatch but I can't pass the MAPIOBJECT to the CDO message.

CDO::MessagePtr pMessage;

CComPtr<IUnknown> spUnknown;
spMailItem->get_MAPIOBJECT(&spUnknown);
CComVariant vtTest(spUnknown);
pMessage->PutMAPIOBJECT(vtTest);

the PutMAPIOBJECT failed. Any reasons of failing? I think Redemption can
attach to existing MAPI MailItem, but can it add additional hidden field to
the mail like CDO?

CDO::FieldsPtr pMessageFields = pMessage->Fields;
pMessageFields->Add(.....)

thanks.
 
D

Dmitry Streblechenko \(MVP\)

A message in CDO cannot be associated with an existing IMessage from
Extended MAPI. You can either use Extended MAPI directly or use Redemption
(it gets associated with an existing message when you set the Safe*Item.Item
property).
Why can't you use MailItem.UserProperties collection in the Outlook Object
Model?

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

Semut

Yup, just figure it later, Userproperties.
By the way, I notice that the IPM.StickyNote Note item do not have the
Userproperties, I add it to ItemProperties instead, is it ok? Any potential
problems? Any precautions?

thank you.
 

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