Creating a new Outlook store
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(olTmpFold开发者_如何学JAVAer.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
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
}
}
精彩评论