How to create mail item in OL 2007 using MAPI

I

Ivan

I create mail items using MAPI. It works fine in OL XP/2003.
But when I try to set some properties in OL 2007 I have MAPI_E_NO_ACCESS
error:
hr = spMsg->SetProps(sizeof(props) / sizeof(props[0]), (LPSPropValue)&props,
NULL); // hr == MAPI_E_NO_ACCESS.
After that I see created mail item in given folder but only the recipient
property is filled.

So, how can I fill other message properties in OL 2007 using MAPI ?
 
I

Ivan

I set these message properties:
PR_SUBJECT;
PR_BODY;
PR_SENDER_EMAIL_ADDRESS;
PR_SENDER_NAME;
PR_SENDER_ADDRTYPE;
PR_SENT_REPRESENTING_EMAIL_ADDRESS;
PR_SENT_REPRESENTING_NAME;
PR_SENT_REPRESENTING_ADDRTYPE;
PR_MESSAGE_FLAGS;
PR_CLIENT_SUBMIT_TIME;
PR_CREATION_TIME;
PR_MESSAGE_CLASS;
PR_EMAIL_ADDRESS;
PR_DISPLAY_TO;
PR_DEFAULT_PROFILE;
PR_AUTO_FORWARDED;

and for recipient:
PR_RECIPIENT_TYPE
PR_ADDRTYPE
PR_EMAIL_ADDRESS
PR_DISPLAY_NAME

// Message creation:
hr = pMAPILogonEx( 0L, NULL, NULL, ulFlags, &spIMAPISession );
hr = spIMAPISession->OpenMsgStore( ..., MAPI_BEST_ACCESS | MDB_WRITE,
&spIMsgStore );
hr = spIMsgStore->OpenEntry( ..., MAPI_BEST_ACCESS, ..., &spSentFolder );
hr = spSentFolder->CreateMessage( NULL, 0, &spMsg );
// ... filling properrties here
hr = spMsg->SaveChanges( FORCE_SAVE );
 
D

Dmitry Streblechenko

You cannot set the PR_CREATION_TIME property.
Why do you set the PR_DEFAULT_PROFILE property?

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

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