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

Testing and Sending email via SMTP using Opportunistic TLS and oAuth in Office365 with PowerShell

As well as EWS and Remote PowerShell (RPS) other mail protocols POP3, IMAP and SMTP have had OAuth authentication enabled in Exchange Online (Official announcement here ). A while ago I created  this script that used Opportunistic TLS to perform a Telnet style test against a SMTP server using SMTP AUTH. Now that oAuth authentication has been enabled in office365 I've updated this script to be able to use oAuth instead of SMTP Auth to test against Office365. I've also included a function to actually send a Message. Token Acquisition  To Send a Mail using oAuth you first need to get an Access token from Azure AD there are plenty of ways of doing this in PowerShell. You could use a library like MSAL or ADAL (just google your favoured method) or use a library less approach which I've included with this script . Whatever way you do this you need to make sure that your application registration  https://docs.microsoft.com/en-us/azure/active-directory/develop/quickstart-register-

How to test SMTP using Opportunistic TLS with Powershell and grab the public certificate a SMTP server is using

Most email services these day employ Opportunistic TLS when trying to send Messages which means that wherever possible the Messages will be encrypted rather then the plain text legacy of SMTP.  This method was defined in RFC 3207 "SMTP Service Extension for Secure SMTP over Transport Layer Security" and  there's a quite a good explanation of Opportunistic TLS on Wikipedia  https://en.wikipedia.org/wiki/Opportunistic_TLS .  This is used for both Server to Server (eg MTA to MTA) and Client to server (Eg a Message client like Outlook which acts as a MSA) the later being generally Authenticated. Basically it allows you to have a normal plain text SMTP conversation that is then upgraded to TLS using the STARTTLS verb. Not all servers will support this verb so if its not supported then a message is just sent as Plain text. TLS relies on PKI certificates and the administrative issue s that come around certificate management like expired certificates which is why I wrote th

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 Graph is limited to a m
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.