A Microsoft Outlook email forum. Outlook Banter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Add-ins for Outlook
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

How to create mail item in OL 2007 using MAPI



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old October 16th 07, 11:43 AM posted to microsoft.public.outlook.program_addins
Ivan
external usenet poster
 
Posts: 39
Default How to create mail item in OL 2007 using MAPI

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 ?
  #2  
Old October 16th 07, 06:44 PM posted to microsoft.public.outlook.program_addins
Dmitry Streblechenko
external usenet poster
 
Posts: 2,116
Default How to create mail item in OL 2007 using MAPI

What are the properties that you set? How do you open spMsg?

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

"Ivan" wrote in message
...
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 ?



  #3  
Old October 17th 07, 05:04 AM posted to microsoft.public.outlook.program_addins
Ivan
external usenet poster
 
Posts: 39
Default How to create mail item in OL 2007 using MAPI

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 );

  #4  
Old October 17th 07, 06:29 AM posted to microsoft.public.outlook.program_addins
Dmitry Streblechenko
external usenet poster
 
Posts: 2,116
Default How to create mail item in OL 2007 using MAPI

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

"Ivan" wrote in message
...
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 );



  #5  
Old October 23rd 07, 08:18 AM posted to microsoft.public.outlook.program_addins
Ivan
external usenet poster
 
Posts: 39
Default How to create mail item in OL 2007 using MAPI

Thanks! The problem was in these properties and PR_DISPLAY_TO.
 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Outlook 2007 on Windows Vista - can't programatically create a MAPI profile Stuart Bray Outlook and VBA 8 February 21st 07 09:37 PM
Adding a header item with MAPI Tom at GSD Add-ins for Outlook 9 January 8th 07 06:54 PM
Item.Save and Item.Close Script causes Outlook 2007 to Crash Rayyan Outlook - Using Forms 6 November 25th 06 03:14 AM
How can I create a outlook appointment item from data in a e-mail? StoltHD Outlook and VBA 6 June 17th 06 08:00 AM
How can I create a outlook appointment item from data in a e-mail? Eric Legault [MVP - Outlook] Outlook and VBA 0 June 15th 06 06:23 PM


All times are GMT +1. The time now is 12:31 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2025 Outlook Banter.
The comments are property of their posters.