Save the item (spCustomItem->Save()) before moving it.
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
This is the code I am usiing through MAPI. I cut and pasted some of my
code.
void CreateCustomMailItem()
{
// Create new mail item
CComQIPtr<Outlook::_MailItem> spCustomItem =
m_spApplication->CreateItem(Outlook:
lMailItem);
// Get message component
IUnknownPtr pUnk = spCustomItem->GetMAPIOBJECT();
CComQIPtr<IMessage, &IID_IMessage> spMessage(pUnk);
// Set MAPI property (I hard coded a MAPI property for this example - I
have tried many)
SetProperty(spMessage, _T("(e-mail address removed)") ;
// Move item to custom folder
spCustomItem->Move(m_spCustomEventFolder);
}
HRESULT SetProperty(CComQIPtr<IMessage, &IID_IMessage> spMessage,
LPCTSTR
szValue)
{
HRESULT hr;
MAPINAMEID NamedProp;
NamedProp.ulKind = MNID_STRING;
MAPINAMEID* pNamedProp = &NamedProp;
LPSPropTagArray lpTags = 0;
SPropValue prop;
char szVal[500] = {NULL};
#ifdef _UNICODE
char* pAnsiData = NULL;
UnicodeToAnsi(szValue, &pAnsiData);
strcpy(szVal, pAnsiData);
CoTaskMemFree(pAnsiData);
#else
strcpy(szVal, szValue);
#endif
// tried numerous properties
prop.ulPropTag =
PROP_TAG(PT_STRING8,PROP_ID(PR_SENDER_EMAIL_ADDRESS_A));
prop.Value.lpszA = (LPSTR)szVal;
// Return S_OK all the time - but the values never change
hr = HrSetOneProp((LPMAPIPROP)(IUnknown*)spMessage, &prop );
MAPIFreeBuffer(lpTags);
return hr;
}
:
Sender properies are not settable in the Outlook Obejct Model.
You really need to show your code.
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
I added a PST file that will store my custom items.
I have created a _MailItem and I cannot set the date or any of the
email
address properties (sender and recipient). It seems like most of the
properties are not accessible until I send the message.
I am creating a mail item and moving it to my custom folder. I want
to
be
able to set all properties (through MAPI or the Outlook classes) at
any
time.
When I try to set properties through MAPI my functionality returns a
success
(S_OK) - but the properties are never set. Am I missing something?
BTW - the book you recommended is excellent. (Inside MAPI)
:
Do you mean you wrote a custom MAPI store provider or that you
added a
PST
store where you store your custom items?
What prevents you from creating your own class that references
MailItem
internally and exposes your custom properties?
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
Hi,
I have created an ATL C++ Outlook plug-in for Outlook 2003.
I would like to create a custom _MailItem object; that I can
control
all
of
the properties at any time. Is this possible?
I have created my own store with custom folders for custom
events.
It
so
happens that the _MailItem object has all of the properties that
I
need
for
custom object within my folder array. I want to be able to set
the
date
properties, to & from properties, read and unread properties, and
a
few
other
properties. When I create the _MailItem object I cannot gain
access
to
a
few
of the properties without performing ugly procedures - does
anybody
have
any
suggestions?
I have a method that will work but it is really ugly and I want
to
make
this
a little more robust. Any suggestions would be greatly
appreciated.
Thanks,
Tom -