Thursday, July 10, 2008

Mail enabling a Public Folder using Exchange Web Services in Exchange 2007

A quick one from the mail bag if you are creating public folders using Exchange Web Services and you want these folders to be mail enalbed without needing to use the Exchange Management Shell or the Public Folder Management console in SP1. Then you can still do this using the same method that worked in Exchange 2000/3 by setting the following two Mapi properties

PR_PUBLISH_IN_ADDRESS_BOOK = 0x3FE6000B
PR_PF_PROXY_REQUIRED = 0x671F000B

So in a CreateFolder Request you need something like

CreateFolderType cfCreateFolder = new CreateFolderType();
PathToExtendedFieldType PR_PUBLISH_IN_ADDRESS_BOOK = new PathToExtendedFieldType();
PR_PUBLISH_IN_ADDRESS_BOOK.PropertyTag = "0x3FE6";
PR_PUBLISH_IN_ADDRESS_BOOK.PropertyType = MapiPropertyTypeType.Boolean;
PathToExtendedFieldType PR_PF_PROXY_REQUIRED = new PathToExtendedFieldType();
PR_PF_PROXY_REQUIRED.PropertyTag = "0x671F";
PR_PF_PROXY_REQUIRED.PropertyType = MapiPropertyTypeType.Boolean;
ExtendedPropertyType pbPubAddressbook = new ExtendedPropertyType();
ExtendedPropertyType prProxyRequired = new ExtendedPropertyType();
pbPubAddressbook.ExtendedFieldURI = PR_PUBLISH_IN_ADDRESS_BOOK;
prProxyRequired.ExtendedFieldURI = PR_PF_PROXY_REQUIRED;
pbPubAddressbook.Item = "1";
prProxyRequired.Item = "1";
FolderType nfNewFolder = new FolderType();
nfNewFolder.ExtendedProperty = new ExtendedPropertyType[2];
nfNewFolder.ExtendedProperty[0] = prProxyRequired;
nfNewFolder.ExtendedProperty[1] = pbPubAddressbook;
nfNewFolder.DisplayName = nfNewFolderName;
TargetFolderIdType tfTargetFolder = new TargetFolderIdType();
cfCreateFolder.ParentFolderId = new TargetFolderIdType();
cfCreateFolder.ParentFolderId.Item = pfParentFolder;
cfCreateFolder.Folders = new FolderType[] { nfNewFolder };
CreateFolderResponseType cfResponse = esb.CreateFolder(cfCreateFolder);

1 comment:

Anonymous said...

Hey Glenn,

I was wondering how you would combine two existing object properties into one? I.E. $_.firstname + $_.lastname = $_.fullname

Do you need to you the add-member cmdlet?

Thanks,
-Nick