How to create a Custom Contacts Folder in VSTO?
I'm trying to create an empty Contacts folder in Outlook 2007 addin using C# in Visual Studio 2010, but it seems like I can only create a folder in the InBox, is that true?
Below is my code:
private void CreateContactsFolder()
{
Outlook.Folder allContacts = (Outlook.Folder)
this.Application.ActiveExplorer().Session.GetDefaultFolder
(Outlook.OlDefaultFolders.olFolderContacts);
Outlook.MAPIFolder customFolder = null;
string folderName = "All Contacts";
customFolder = (Outlook.Folder)allContacts.Folders.
Add(allContact开发者_如何学编程s, Outlook.OlDefaultFolders.olFolderContacts);
}
You can create a folder under "Contacts" by specifying the type of folder you need.
Outlook.NameSpace outlookNameSpace = application.GetNamespace("MAPI");
Outlook.MAPIFolder contactsFolder =
outlookNameSpace.GetDefaultFolder(
Outlook.OlDefaultFolders.olFolderContacts);
MAPIFolder ContactsSubFolder = contactsFolder.Folders.Add("Contacts Sub Folder", Outlook.OlDefaultFolders.olFolderContacts);
精彩评论