How to change Parent property of outlook item

  • Thread starter Thread starter Iwi
  • Start date Start date
I

Iwi

I am using CreateItemFromTemplate, and the template being a *.msg of a
mail from inbox. Problem: The new item will have draft as parent
folder. I want to save the newly created item back to inbox. So I save
the item on drafts and move it to inbox. Problem is that the newly
created item's parent property is still drafts (and you can even see
that the item's icon is different than any other items in inbox, and I
find no way to change this property since it is a read-only.
here's my program:

Set ol = New Outlook.Application
Set olns = ol.GetNamespace("MAPI")
Set oFolder = olns.GetDefaultFolder(olFolderInbox)
Set oMail = oFolder.Items.GetLast()
oMail.SaveAs "C:\OutlookTest.MSG"
Set oNewItem = ol.CreateItemFromTemplate("C:\OutlookTest.MSG",
oFolder)
Set oNewItem2 = oNewItem.Copy
Set oNewItem = Nothing
''oNewItem.Move oFolder
oNewItem2.Move oFolder
ViewMailProperties (oMail)
ViewMailProperties2 (oNewItem)

Anybody knows ways to do this so that I can get the parent property as
my desired folder? Thank you.
 
Replace
oNewItem2.Move oFolder
with
set oNewItem2 = oNewItem2.Move(oFolder)
oNewItem2.Save


Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
 
Thank you for your prompt reply Dmitry. I've tried your solution and
not I am able to save the item in the right folder. This does not
solve the other problem I am having which is the newly created
message's icon is not a received item, hence it is a new message
instead of a received message. In my code, I am saved the the *.msg
file from inbox as a received mail. Is there anyway to restore this
file to my PST file as a received mail, not as a new message
programmatically? Thank you
 
Sent/unsent flag is read-write until the first save only and Outlook always
sets to what it thinks is appropriate.
Create the message as olPostItem (it is created in the sent state), save it,
then set the message class to "IPM.Note". The next time you open the
message, it will be a regular MailItem in the sent state.

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
 
Sorry, I didn't realize you are using CreateItemFromTemplate - you are stuck
in this case.
Your only solution would be to use Extended MAPI (C++/Delphi only) or use
Redemption (SafeMailItem.Import) along with the workaround I outlined in my
previous post.

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