EWS extended property definition for appointments

This topic contains 2 replies, has 2 voices, and was last updated by  Manuel Berfelde 1 week, 1 day ago.

  • Author
    Posts
  • #83998

    Manuel Berfelde
    Participant

    Hi,

    I am currently trying to add a custom property to an appointment in Exchange via EWS. Unfortunatley I am little stuck here.
    I found examples for C# and VB but I cannot connect the dots to make it work in powershell even though I am pretty far, I think/hope.
    Connecting, binding, viewing and editing existing items and their properties all works fine but I cannnot find a way to add a custom field/property to an calendar item.

    Here is what I found so far (as I said no PS):
    https://msdn.microsoft.com/en-us/library/office/dd633654(v=exchg.80).aspx
    https://stackoverflow.com/questions/24526704/ews-create-appointment-in-exchange-with-extra-custom-properties
    http://www.independentsoft.de/exchangewebservices/tutorial/createcontactwithcustomproperty.html

    Any help is appreciated. Thanks!

  • #83999

    postanote
    Participant

    The is no native way to do this via PsSH, yet, as noted, PoSH has full access to the .Net framework just like other MS Dev tools and others.

    You have to take the guidance dev links, an incorporate the code / classes or create a class of your own making then use that class in your script.

    See this guidance:
    'social.technet.microsoft.com/wiki/contents/articles/27080.powershell-how-to-create-and-use-classes.aspx'
    'blogs.technet.microsoft.com/heyscriptingguy/2012/02/11/why-use-net-framework-classes-from-within-powershell'
    'blogs.technet.microsoft.com/heyscriptingguy/2010/11/11/use-powershell-to-work-with-the-net-framework-classes'
    'trevorsullivan.net/2014/10/25/implementing-a-net-class-in-powershell-v5'

    See also the following for implementation ideas:
    github.com/ChendrayanV/EWS-API-PowerShell-Scripts'

    Point of note...
    'blogs.office.com/en-us/2014/09/25/ews-managed-api-net-now-open-source'

  • #84037

    Manuel Berfelde
    Participant

    Thanks for the response. Turns out I really was close.

    As I said, I had been able to create an appointment.
    To add a custom property to this appointment, you have to create an ExtendedPropertyDefinition-object, which requires a GUID:

    $myGUID = [GUID]"32ed071d-932e-487e-ad14-cde3272cfcc7"
    $myProperty = new-object Microsoft.Exchange.WebServices.Data.ExtendedPropertyDefinition(`
                    $myGUID,`       # property GUID
                    "myProperty",`  # property name
                    [Microsoft.Exchange.WebServices.Data.MapiPropertyType]::string` # property type
                  )

    Then you can use the SetExtendedProperty-method of the existing appointment, to add an instance of the defined property to the appointment:

    $appointment.SetExtendedProperty($myProperty,"This is my String")

    Finally you update the appointment:

    $appointment.update("AlwaysOverwrite")

    That's all.

    I found everything I had been missing here:

You must be logged in to reply to this topic.