Skip to main content


Showing posts from July, 2013

Sending a VoiceMail using EWS and Powershell

If you want to send a VoiceMail via EWS and have the UM controls appear in Outlook and OWA so it appears the same as it was generated from Exchange UM you need to set a number of different extended properties on an Email Message when you send it. The full list of properties is documented in the following Exchange Protocol document . While some of these properties are optional the most important is to the set the PidTagVoiceMessageAttachmentOrder property which needs to be set to the name of the attachment. You also need to make sure you set the ItemClass to IPM.Note.Microsoft.Voicemail.UM.CA . The following is a sample of sending a mp3 voicemail as a message with powershell, I've put a download of this script here . ## Get the Mailbox to Access from the 1st commandline argument       $MailboxName  =  $args [0]      #MessageProperties       $VoiceMailSuject  =  "Voice Mail from .."

Forwarding a Message as an Attachment using the EWS Managed API and Powershell

While you can easily create an Inbox rule to forward a Message as an Attachment, doing this programmatically in EWS isn't that straight forward. As there is no direct method in EWS to attach an existing Store item a work around is needed. With this workaround we use the MimeContent of an existing email message which will allow you to create an ItemAttachment of this existing message (using the method from this post) in the Inbox and maintain all the Mime Properties and attachments on the message your forwarding. Note this method doesn't maintain full fidelity of a Message as it won't include any MAPI properties or Exchange rich datatypes which may or may not be important. The following sample demonstrates how to forward the more recently received email in the Inbox as an Item Attachment using the MimeContent (and also setting the MessageFlags property to make sure the message appears sent).  $folderid=  new -object Microsoft.Exchange.WebServices.Data.FolderId([Micro

Creating Item Attachments with the EWS Managed API with Powershell

Item Attachments in EWS allow you to create an Attachment that is of a Rich Exchange type such as an EmailMessage, Task, Post, Contact etc or even your own custom form if your using these. Although one thing you can't do with an Item attachment is attach an existing Exchange Item. To use ItemAttachments in Powershell you need to use reflection in .NET as it involves invoking a Generic Method which is not that straight forward in Powershell. The following is an example of creating a Task as an Item Attachment in Powershell using reflection $mail  =  New-Object  Microsoft.Exchange.WebServices.Data.EmailMessage( $service );   $AtColtype  = ( "Microsoft.Exchange.WebServices.Data.AttachmentCollection" ) -as  "Type"    $Tasktype  = ( "Microsoft.Exchange.WebServices.Data.Task" ) -as  "Type"    $methodInf  =  $AtColtype .GetMethod( "AddItemAttachment" );   $AddItmAttachMethod  =  $methodInf .MakeGenericMethod( $Tasktype );
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.