0
votes

I am creating a pst file in Outlook using C#, and Addin express.

The new pst file ("My Inbox") should have Inbox,Sent Items, Outbox.

Outlook.Folders olFolders = olNamespace.Folders;
        foreach (Outlook.MAPIFolder olTmpFolder in (IEnumerable) olFolders)
        {

            if(olTmpFolder.Name == "My Inbox")
            {

                olTmpFolder.Folders.Add("Inbox", Outlook.OlDefaultFolders.olFolderInbox);
                olTmpFolder.Folders.Add("Sent", Outlook.OlDefaultFolders.olFolderSentMail);
                olTmpFolder.Folders.Add("Outbox", Outlook.OlDefaultFolders.olFolderOutbox);

            }

        }

But I can only see the Inbox folder .

If there are better ways please let me know.

Thanks Sujay

1

1 Answers

0
votes

Try this and let me know if it works:

Outlook.Folders olFolders = olNamespace.Folders;
        foreach (Outlook.MAPIFolder olTmpFolder in (IEnumerable) olFolders)
        {
            if(olTmpFolder.Name == "My Inbox")
            {

                olTmpFolder.Folders.Add("Inbox", missing) as Outlook.Folder;
                olTmpFolder.Folders.Add("Sent", missing) as Outlook.Folder
                olTmpFolder.Folders.Add("Outbox", missing) as Outlook.Folder
            }
        }