Items.Add doesn't add an item

  • Thread starter Thread starter David
  • Start date Start date
D

David

Regarding the following C# code:

private Outlook.MAPIFolder CreateMyMapiFolder(Outlook.MAPIFolder parent, String folderName, String body)

{

Outlook.MAPIFolder newFolder = parent.Folders.Add(folderName, Outlook.OlDefaultFolders.olFolderInbox);



Outlook.PostItem pi = newFolder.Items.Add("IPM.Post") as Outlook.PostItem;

pi.Body = body;


System.Diagnostics.Debug.Print(newFolder.Items.Count.ToString());

return newFolder;

}

When I call the function it runs without any errors, but the items count remains zero.
Do I need to do some kind of commit?
What am I missing?
 
call pi.Save()

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
Regarding the following C# code:

private Outlook.MAPIFolder CreateMyMapiFolder(Outlook.MAPIFolder parent, String folderName, String body)

{

Outlook.MAPIFolder newFolder = parent.Folders.Add(folderName, Outlook.OlDefaultFolders.olFolderInbox);



Outlook.PostItem pi = newFolder.Items.Add("IPM.Post") as Outlook.PostItem;

pi.Body = body;

pi.Save()


System.Diagnostics.Debug.Print(newFolder.Items.Count.ToString());

return newFolder;

}

When I call the function it runs without any errors, but the items count remains zero.
Do I need to do some kind of commit?
What am I missing?
 
Back
Top