Skip to main content

Turning the Reading / Preview pane on and off in OWA in Exchange 2007 with EWS and Powershell

The Reading pane (or preview pane) is one the features of the premium version of Outlook Web Access on 2007. Due to Security or bandwidth (or other) worries you may want to turn this off on particular folders for your users (although they will still be able to still turn this back on using OWA). There is no global way of turnin it off so you need to modify the property that controls this on each folder you want to be affected.

The property that controls the Preview pane is http://schemas.microsoft.com/exchange/preview this doesn't get set by default so in the absence of this property the preview pane is on. If the property does exist it will be one of three values

0 - Preview Pane is off
1 - Preview Pane set to rights
2 - Preview Pane set to bottom

To set this property you can use any of the Exchange API's on 2007 the best API to use is EWS in C# if you wanted to set this property you would need to use the following property definition in a FolderUpdate Operation

PathToExtendedFieldType ppainprop = new PathToExtendedFieldType();
ppainprop.PropertyName = "http://schemas.microsoft.com/exchange/preview";
ppainprop.PropertyType = MapiPropertyTypeType.String;
ppainprop.DistinguishedPropertySetIdSpecified = true;
ppainprop.DistinguishedPropertySetId = DistinguishedPropertySetType.PublicStrings;

I've put together some methods in my EWS Powershell library to allow some easy PSH code to query and update this value on mailbox folders. I've created two seperate versions of a sample script to do this the first just sets this property on the inbox folder while the second loops through every mailbox folder and sets this property on every folder in a mailbox.

To use this script you need my ewsutil library which contains the EWS code you can download this from http://msgdev.mvps.org/exdevblog/ewsutil.zip.For more information on using the library and connection and authentication options this is documented in another post.

I've posted both versions of the script here the version that loops through all folders looks like

$setPPTo = "0"

[void][Reflection.Assembly]::LoadFile("C:\temp\EWSUtil.dll")
$casUrl = "https://servername/ews/exchange.asmx"
$mbMailboxEmail= "user@domain.com"
$ewc = new-object EWSUtil.EWSConnection("user@domain.com",$false, "username", "Password", "domain",$casUrl)

$fldarry = new-object EWSUtil.EWS.BaseFolderIdType[] 1
$dTypeFld = new-object EWSUtil.EWS.DistinguishedFolderIdType
$dTypeFld.Id = [EWSUtil.EWS.DistinguishedFolderIdNameType]::msgfolderroot
$mbMailbox = new-object EWSUtil.EWS.EmailAddressType
$mbMailbox.EmailAddress = $mbMailboxEmail
$dTypeFld.Mailbox = $mbMailbox
$fldarry[0] = $dTypeFld

$FolderList = $ewc.GetAllMailboxFolders($fldarry)
$fldarry1 = new-object EWSUtil.EWS.BaseFolderIdType[] $FolderList.Count
for ($fcint=0;$fcint -lt $FolderList.Count;$fcint++){
$fldarry1[$fcint] = $FolderList[$fcint].FolderId
}
$psPreviewSetting = new-object EWSUtil.EWS.PathToExtendedFieldType
$psPreviewSetting.DistinguishedPropertySetIdSpecified = $true
$psPreviewSetting.DistinguishedPropertySetId = [EWSUtil.EWS.DistinguishedPropertySetType]::PublicStrings
$psPreviewSetting.PropertyName = "http://schemas.microsoft.com/exchange/preview"
$psPreviewSetting.PropertyType = [EWSUtil.EWS.MapiPropertyTypeType]::Integer
$beparray = new-object EWSUtil.EWS.BasePathToElementType[] 1
$beparray[0] = $psPreviewSetting
$Folders = $ewc.GetFolder($fldarry1,$beparray)
If ($Folders.Count -ne 0) {
ForEach ($Folder in $Folders) {
$cval = "n/a"
if ($Folder.extendedProperty -ne $null){
$cval = $Folder.extendedProperty[0].Item.ToString()
switch ($Folder.extendedProperty[0].Item.ToString()){
0 { $Folder.DisplayName + " Preview Pane Set Off"}
1 { $Folder.DisplayName + " Preview Pane Set Right"}
2 { $Folder.DisplayName + " Preview Pane Set Bottom"}
}
}
else{
$Folder.DisplayName + " Not set will default to On"
}
if ($cval -ne $setPPTo){
$exProp = new-object EWSUtil.EWS.ExtendedPropertyType
$exProp.ExtendedFieldURI = $psPreviewSetting
$exProp.Item = $setPPTo
$ewc.UpdateFolderExtendedProperty($exProp,$Folder)
}
}
}

Popular posts from this blog

Exporting and Uploading Mailbox Items using Exchange Web Services using the new ExportItems and UploadItems operations in Exchange 2010 SP1

Two new EWS Operations ExportItems and UploadItems where introduced in Exchange 2010 SP1 that allowed you to do a number of useful things that where previously not possible using Exchange Web Services. Any object that Exchange stores is basically a collection of properties for example a message object is a collection of Message properties, Recipient properties and Attachment properties with a few meta properties that describe the underlying storage thrown in. Normally when using EWS you can access these properties in a number of a ways eg one example is using the strongly type objects such as emailmessage that presents the underlying properties in an intuitive way that's easy to use. Another way is using Extended Properties to access the underlying properties directly. However previously in EWS there was no method to access every property of a message hence there is no way to export or import an item and maintain full fidelity of every property on that item (you could export the...

The MailboxConcurrency limit and using Batching in the Microsoft Graph API

If your getting an error such as Application is over its MailboxConcurrency limit while using the Microsoft Graph API this post may help you understand why. Background   The Mailbox  concurrency limit when your using the Graph API is 4 as per https://docs.microsoft.com/en-us/graph/throttling#outlook-service-limits . This is evaluated for each app ID and mailbox combination so this means you can have different apps running under the same credentials and the poor behavior of one won't cause the other to be throttled. If you compared that to EWS you could have up to 27 concurrent connections but they are shared across all apps on a first come first served basis. Batching Batching in the Graph API is a way of combining multiple requests into a single HTTP request. Batching in the Exchange Mail API's EWS and MAPI has been around for a long time and its common, for email Apps to process large numbers of smaller items for a variety of reasons.  Batching in the Gr...

Sending a Message in Exchange Online via REST from an Arduino MKR1000

This is part 2 of my MKR1000 article, in this previous post  I looked at sending a Message via EWS using Basic Authentication.  In this Post I'll look at using the new Outlook REST API  which requires using OAuth authentication to get an Access Token. The prerequisites for this sketch are the same as in the other post with the addition of the ArduinoJson library  https://github.com/bblanchon/ArduinoJson  which is used to parse the Authentication Results to extract the Access Token. Also the SSL certificates for the login.windows.net  and outlook.office365.com need to be uploaded to the devices using the wifi101 Firmware updater. To use Token Authentication you need to register an Application in Azure https://msdn.microsoft.com/en-us/office/office365/howto/add-common-consent-manually  with the Mail.Send permission. The application should be a Native Client app that use the Out of Band Callback urn:ietf:wg:oauth:2.0:oob. You ...
All sample scripts and source code is provided by for illustrative purposes only. All examples are untested in different environments and therefore, I cannot guarantee or imply reliability, serviceability, or function of these programs.

All code contained herein is provided to you "AS IS" without any warranties of any kind. The implied warranties of non-infringement, merchantability and fitness for a particular purpose are expressly disclaimed.