CDO programming - CDO::Message

  • Thread starter Thread starter Semut
  • Start date Start date
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.
 
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
 
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.
 
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
 
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.
 
Back
Top