Don't know about the CreateItemFromTemplate problem, but for the
disappearing properties, save the item first (moItem.Save), then add named
properties using Redemption, then try to mark the item as dirty
(moItem.Subject=moItem.Subject would do), then save again.
In the worst case you can reopen the item using MAPIUtils.GetItemFromID and
then set the named props.
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
> My app (VB6) imports an task from a .msg file with the
> .CreateItemFromTemplate statement:
[quoted text clipped - 20 lines]
>
> Ronald van Aalten
Ken Slovak - [MVP - Outlook] - 28 Oct 2005 14:50 GMT
There is a known problem with Post forms and CreateItemFromTemplate and then
publishing a custom form using code. I'm not sure about task forms.

Signature
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Absolute Beginner's Guide to Microsoft Office Outlook 2003
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm
> Don't know about the CreateItemFromTemplate problem, but for the
> disappearing properties, save the item first (moItem.Save), then add named
[quoted text clipped - 7 lines]
> OutlookSpy - Outlook, CDO
> and MAPI Developer Tool
Ronald van Aalten - 28 Oct 2005 15:38 GMT
Hi Dmitry,
I already tried exactly what you are describing but to no avail.
The problem is related to the fact that I specifiy a folder in the
CreateItemFromTemplate method other then the item's default folder. If I
repeat my tests with a task in the default Tasks folder then there's no
problem, all named properties remain.
Here's a piece of my coding:
Set moItemOther = goOutl.CreateItemFromTemplate(msMsgFile, moOlFld)
' test if the item is imported in the correct folder, if not move it:
If moItemOther.Parent.EntryID <> moOlFld.EntryID Then
moItemOther.Save
moItemOther.Move moOlFld
End If
moItemOther.Save
sTemp = moItemOther.EntryID
Set moItemOther = Nothing
Set moItemOther = goredUtil.GetItemFromID(sTemp, moOlFld.EntryID)
goAppProc.SetPropsInNamedProps moItemOther ' here the named
properties are set
before this procedure finishes I print the item ID which is saved in a named
property:
Debug.Print "id= " & goFldMon.GetItemID(moItemOther) ' this
returns the ID from the named property
here I see the CORRECT id so the named property is still there.
Then I open the task in outlookspy and... all the named properties,
including the ID are gone...
I have several customers who are reporting problems which can be traced back
to this behaviour. They ALL have SP2 installed.... Unfortunately on all my
computers I have applied sp2 already so can't test without sp2 anymore or
I'll have to reinstall outlook.
Do you have any more ideas?
Ronald
> Don't know about the CreateItemFromTemplate problem, but for the
> disappearing properties, save the item first (moItem.Save), then add named
[quoted text clipped - 32 lines]
>>
>> Ronald van Aalten
Dmitry Streblechenko - 28 Oct 2005 17:49 GMT
Move is a function that returns the new item, not a sub. The old item is no
longer valid and must be immediately released.
Change the line
moItemOther.Move moOlFld
to
set moItemOther = moItemOther.Move(moOlFld)
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
> Hi Dmitry,
>
[quoted text clipped - 69 lines]
>>>
>>> Ronald van Aalten
Ronald van Aalten - 29 Oct 2005 16:52 GMT
Dmitry, it all doesn't work. Please see my reply to Ken.
Ronald
> Move is a function that returns the new item, not a sub. The old item is
> no longer valid and must be immediately released.
[quoted text clipped - 82 lines]
>>>>
>>>> Ronald van Aalten
Ronald van Aalten - 30 Oct 2005 13:36 GMT
Hi Dmitry,
I found the solution. The problem was that MAPIUtils.GetItemFromID doesn't
work but NameSpace.GetItemFromID does.
Here's the code that works:
Set moItemOther = goOutl.CreateItemFromTemplate(msMsgFile, moOlFld)
moItemOther.Save
' the CreateItemFromTemplate method imports ALWAYS in the default
folder after Outlook 2003 SP2
' is installed. Also SP2 change: named props are lost. Workaround:
move explicitly;
' save and recreate object before setting the named props.
If moItemOther.Parent.EntryID <> moOlFld.EntryID Then
Set moItemOther = moItemOther.Move(moOlFld)
End If
DoEvents
Sleep 100
moItemOther.Subject = moItemOther.Subject
moItemOther.Save
sTemp = moItemOther.EntryID
Set moItemOther = Nothing
'Set moItemOther = goredUtil.GetItemFromID(sTemp, moOlFld.EntryID)
' doesn't work; moItemOther is nothing so use namespace method:
Set moItemOther = goNS.GetItemFromID(sTemp)
About the named properties that were lost: I now understand this is by
design in SP2 after reading this article:
http://support.microsoft.com/kb/907985/en-us?spid=2520
Ronald
> Move is a function that returns the new item, not a sub. The old item is
> no longer valid and must be immediately released.
[quoted text clipped - 82 lines]
>>>>
>>>> Ronald van Aalten
Can the file (item) be saved as an OFT file? See if that helps with SP2.

Signature
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Absolute Beginner's Guide to Microsoft Office Outlook 2003
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm
> My app (VB6) imports an task from a .msg file with the
> .CreateItemFromTemplate statement:
[quoted text clipped - 20 lines]
>
> Ronald van Aalten
Ronald van Aalten - 29 Oct 2005 16:51 GMT
Hi Ken,
No, .oft doesn't work. It already didn't work before SP2. An .oft file saved
with the redemption SaveAs can't be imported either with
oOutlook.CreateItemFromTemplate or with redemption's
utils.GetItemFromMsgFile or with redemption's item.import.
I did find a way to import the item from a .msg file in the correct folder
and to retain it's named properties:
Set moItemOther = moOlFld.Items.Add()
moredApp.item = moItemOther
moredApp.Import msMsgFile, olMSG
BUT...
this totally messes up the recurrance info. So a recurrant appointment saved
in the .msg file and imported again (on another computer) by the above code
has totally wrong recurrance info! Even the item.isrecurring property isn't
correct anymore, it's now always false.
So this workaround for the broken .CreateItemFromTemplate method brings me
in another mess... Before SP2 and by using the .CreateItemFromTemplate
method the recurrance info stayed the same between exporting and exporting a
msg file.
Ronald
> Can the file (item) be saved as an OFT file? See if that helps with SP2.
>
[quoted text clipped - 22 lines]
>>
>> Ronald van Aalten
Ronald van Aalten - 30 Oct 2005 13:37 GMT
Hi Ken, I found the solution, see my last response to Dmitry.
Ronald
> Hi Ken,
>
[quoted text clipped - 46 lines]
>>>
>>> Ronald van Aalten