Jonathan Miller

I'm trying to program Outlook 2007 using VSTO 2005 SE. Basically, I've created a folder with user defined properties. I've created items in the folder and set the properties using the PropertyAccessor. I can even enumerate the items and read back the properties values. However, when I add my UserDefinedColumns to my view there is nothing in them! What is the deal. It makes me think that the values I'm setting through the Item's PropertyAccessor are not the same ones that outlook is using for my UserDefinedProperties. Any help would be appreciated.

Outlook.MAPIFolder NewFolder;

// get rootfolder

Outlook.MAPIFolder RootFolder = m_Application.Session.Stores[2].GetRootFolder();

NewFolder = RootFolder.Folders.Add("TestFolder", Outlook.OlDefaultFolders.olFolderInbox);

NewFolder.UserDefinedProperties.Add("TestField1", Microsoft.Office.Interop.Outlook.OlUserPropertyType.olInteger, Outlook.OlFormatInteger.olFormatIntegerPlain, null);

NewFolder.UserDefinedProperties.Add("TestField2", Microsoft.Office.Interop.Outlook.OlUserPropertyType.olText, Outlook.OlFormatText.olFormatTextText, null);

NewFolder.UserDefinedProperties.Add("TestField3", Microsoft.Office.Interop.Outlook.OlUserPropertyType.olText, Outlook.OlFormatText.olFormatTextText, null);

NewFolder.UserDefinedProperties.Add("TestField4", Microsoft.Office.Interop.Outlook.OlUserPropertyType.olText, Outlook.OlFormatText.olFormatTextText, null);

NewFolder.UserDefinedProperties.Add("TestField5", Microsoft.Office.Interop.Outlook.OlUserPropertyType.olDateTime, Outlook.OlFormatDateTime.olFormatDateTimeShortDateTime, null);

// create new item

Outlook.PostItem NewItem = (Outlook.PostItem)NewFolder.Items.Add(Outlook.OlItemType.olPostItem);

NewItem.Subject = "Test";

NewItem.Body = "nothing";

NewItem.PropertyAccessor.SetProperty("http://schemas.microsoft.com/mapi/string/{FFF40745-D92F-4C11-9E14-92701F001EB3}/TestField1", 12345);

NewItem.PropertyAccessor.SetProperty("http://schemas.microsoft.com/mapi/string/{FFF40745-D92F-4C11-9E14-92701F001EB3}/TestField2", "Test 2");

NewItem.PropertyAccessor.SetProperty("http://schemas.microsoft.com/mapi/string/{FFF40745-D92F-4C11-9E14-92701F001EB3}/TestField3", "Test 3");

NewItem.PropertyAccessor.SetProperty("http://schemas.microsoft.com/mapi/string/{FFF40745-D92F-4C11-9E14-92701F001EB3}/TestField4", "Test 4");

NewItem.PropertyAccessor.SetProperty("http://schemas.microsoft.com/mapi/string/{FFF40745-D92F-4C11-9E14-92701F001EB3}/TestField5", "Test 5");

// post/save item

NewItem.Post();



Re: Visual Studio Tools for Office UserDefined properties displayed empty?

Sue Mosher - Outlook MVP

Your analysis is correct. You're using the GUID specifically for your add-in right That creates hidden properties on the item.

If your goal is to populate visible properties, do that through the PostItem.UserProperties collection. If you still prefer to use SetProperty (which would be less efficient unless you do a SetProperties operation to add properties in bulk), use the GUID that Outlook uses for the UserProperties collection, {00020329-0000-0000-C000-000000000046}.

FYI, this forum is mainly for issues with VSTO itself. There is a newsgroup specifically for general Outlook programming issues "down the hall" at http://www.microsoft.com/office/community/en-us/default.mspx dg=microsoft.public.outlook.program_vba.





Re: Visual Studio Tools for Office UserDefined properties displayed empty?

Jonathan Miller

That worked!