Skip to main content

Posts

Setting single line view in OWA for a folder via Powershell using the EWS Managed API

Early this year i posted a script for turning the reading pain off and on in OWA 2007 using some EWS proxy code in powershell. The same thing can also be done using the EWS Managed API as well as other properties in OWA like the single line view which someone asked about this week. So here is a script that can be used for setting both of these values. Single Line View property, Like the reading pain this OWA setting in controlled by a property that is set on each folder http://schemas.microsoft.com/exchange/wcmultiline To use this in Powershell in the EWS Managed API you need to define a Extended Property using the Public Strings PropertySet eg $wcmultiline = New-Object Microsoft.Exchange.WebServices.Data.ExtendedPropertyDefinition([Microsoft.Exchange.WebServices.Data.DefaultExtendedPropertySet]::PublicStrings," http://schemas.microsoft.com/exchange/wcmultiline ", [Microsoft.Exchange.WebServices.Data.MapiPropertyType]::Boolean); 1 = True mean multiline view is On (Default) 0 ...

Creating Sticky Notes in the EWS Managed API from Powershell

I’m a big user of sticky notes in Outlook and I’m always finding different ways to have fun with them. The EWS Managed API makes creating them relatively simply from powershell as long as you have got a handle on the extended properties that are being used to control the Sticky Notes as well the method of creating objects with different Item class in EWS. Because there are no specific objects within EWS Managed API to help create Sticky notes you need to use a EmailMessage object and change the ItemClass to “IPM.StickyNote”. You also need to set a number of Extended property which control the color and size of the sticknote object. The following sample creates a sticky note in the currently logged on users mailbox I’ve put a download of the code here the code itself looks like $dllpath = "C:\Program Files\Microsoft\Exchange\Web Services\1.0\Microsoft.Exchange.WebServices.dll" [void][Reflection.Assembly]::LoadFile($dllpath) $service = New-Object Microsoft.Exchange.WebService...

Simple Exchange Email client for Powershell using the EWS Managed API

** Updated download to fix issue with 2010 SP1, self signed certs and search *** One thing that is useful now and again when you are testing different problems and configurations on Exchange is to have a Mail client that isn’t Outlook or OWA. Back in the days there used to be a Simple Mapi client called the Exchange client which disappeared after 5.0. While this isn’t a attempt to replace it or to be an end user mail client at all it’s a great little test bench script that allows you to get in and look at mailbox and the items in that mailbox, Download attachments,export single emails, look at Message headers, search for emails and if there is any particular problem you want to tackle in regards to certain properties it’s something that can be very easily adapted to fit an specific problem. How it works This script presents a Winform GUI that allows you to interact with a mailbox and present it into a displayable view back to a user. Okay I could go on like this all day (seriously!!) t...

Using SearchFilter and other Nested Types in the EWS Managed API from Powershell

A SearchFilter in the EWS Managed API gives you the ability to place restrictions on any findItem operations you do on a folder with Exchange Web Services. For instance you can search for a message in a folder based on a subject or words within the subject etc. Both the SearchFilter and Recurrence classes with the EWS Managed API are implemented as Nested Types see http://msdn.microsoft.com/en-us/library/ms229027.aspx for a description as to what these are. To use one of these objects within a NestedType you need to use the following format when initializing it namespace.enclosing type+nested type see http://weblogs.asp.net/soever/archive/2006/12/11/powershell-and-using-net-enum-types.aspx So to declare a IsEqualTo filter use $view = New-Object Microsoft.Exchange.WebServices.Data.ItemView(1) $view.SearchFilter = new-object Microsoft.Exchange.WebServices.Data.SearchFilter+IsEqualTo([Microsoft.Exchange.WebServices.Data.EmailMessageSchema]::IsRead, $false) $findResults = $service.FindIte...

Downloading Attachments and Exporting Email as eml files in the EWS Managed API using Powershell

A common and useful thing you may want to do in Powershell when working with Exchange Email automation is to download an attachment. When working with Exchange Web Services you first need to use a GetItem operation to work out what attachments are on a message then use a GetAttachment operation which returns a Byte Array of each attachments content. So all you need to do with this Byte array is write it out to a file using the System.IO.FileStream Class. To do this you first need a message object that you would normally get doing a GetItem operation in EWS in the managed API its just one line once you know the MessageID. Eg $msMessage = [Microsoft.Exchange.WebServices.Data.EmailMessage]::Bind($service,$MessageID) Once you have the message object you will have a list of attachments and the attachmentID you need to make a GetAttachment operations. Again this is pretty easy to do using the Managed API which extrapolates the GetAttachment operation as the load method on an attachment objec...

Mail Enabling a Public folder with the EWS Managed API and finding and changing the primary email address without using Exchange cmdlets

If your working with Public Folders in the EWS Managed API then you may want to mailenable a new or existing Public Folder without using EMS cmdlets. I described a method that you can use to mail enable Public folders using EWS a while ago here and this same method will work with a little bit of different code. Like the previous post you need to set the following 2 properties to mail enabled a folder. PR_PUBLISH_IN_ADDRESS_BOOK = 0x3FE6000B PR_PF_PROXY_REQUIRED = 0x671F000B So if you want to mailenable an existing folder that you have the path for say its "firstlevel/secondlevel/newfolder" you will first need to have some code that will find the folder based on the path by doing a search. Then once you have the folder ID you can Bind to the folder and set those Mapi properties. Using a UpdateFolder operation was one of the harder operations in normal EWS proxy code but its now so much easier to do in the EWS Managed API. Once you have set these properties a backgroup process ...

Acknowledging Appointment reminders with WebDAV

One thing that can be little tricky if your working in WebDAV is dealing with appointment reminders, especially when you have to deal with recurring appointments. If you dont use the right method its easy to break the recurrance of appointments. The best way of working something like this out is have a look at the way OWA does it and then just use the same xml. So basically what you end up with is firstly a method to acknowledge non-recurring appointment reminders by removing the reminderoffset property. And a method to acknowledge recurring appointment reminders by setting the remindernexttime property. I've put a download of this VBS script here the code looks like eg set req = Createobject("microsoft.xmlhttp") CalendarURL = "https://servername/exchange/mailbox/calendar" AppointmentURL = CalendarURL & "/appointment.eml" If RecurringAppointment = false Then xmlstr = "<?xml version=""1.0""?><a:propertyupdate xm...
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.