none
Retrieve Custom Fields on Outlook Custom Forms through Powershell/EWS? RRS feed

  • Question

  • I'm able to use Powershell and EWS API 1.1 to get a custom form in the public folder but how do I get the values of custom fields such as a textbox or a dropdownlist?  I can get the basic properties of the custom form such as sender, recipient, subject, body, etc.  but not the extendedproperties.  I tried using the trygetproperty method but I'm not really sure how to use it. 

    here's the mapi values of the field i'm trying to read.

    Tag: 0x84FB001E
    Type: PT_STRING8
    DASL: http://schemas.microsoft.com/mapi/string/{00020329-0000-0000-C000-000000000046}/Company Name
    Named Prop Name: sz: "Company Name"
    Named Prop Guid: {00020329-0000-0000-C000-000000000046} = PS_PUBLIC_STRINGS

     

    -Jan

    Thursday, January 27, 2011 9:40 PM

Answers

  • You first need to define the property then add the property to a propertySet and use that propertyset with an itemview eg

     

    $cmpName = new-object Microsoft.Exchange.WebServices.Data.ExtendedPropertyDefinition([Microsoft.Exchange.WebServices.Data.DefaultExtendedPropertySet]::PublicStrings,"Company Name",[Microsoft.Exchange.WebServices.Data.MapiPropertyType]::String);
    $psPropertySet = new-object Microsoft.Exchange.WebServices.Data.PropertySet([Microsoft.Exchange.WebServices.Data.BasePropertySet]::FirstClassProperties)
    $ivItemView.PropertySet = $cmpName
    

    Then use the PropertySet in a load or FindItems operation

    Cheers
    Glen

    • Marked as answer by baker_man Friday, January 28, 2011 6:20 PM
    Friday, January 28, 2011 2:41 AM

All replies

  • You first need to define the property then add the property to a propertySet and use that propertyset with an itemview eg

     

    $cmpName = new-object Microsoft.Exchange.WebServices.Data.ExtendedPropertyDefinition([Microsoft.Exchange.WebServices.Data.DefaultExtendedPropertySet]::PublicStrings,"Company Name",[Microsoft.Exchange.WebServices.Data.MapiPropertyType]::String);
    $psPropertySet = new-object Microsoft.Exchange.WebServices.Data.PropertySet([Microsoft.Exchange.WebServices.Data.BasePropertySet]::FirstClassProperties)
    $ivItemView.PropertySet = $cmpName
    

    Then use the PropertySet in a load or FindItems operation

    Cheers
    Glen

    • Marked as answer by baker_man Friday, January 28, 2011 6:20 PM
    Friday, January 28, 2011 2:41 AM
  • Thanks Glen! That worked.  Looks like I wasn't defining the property correctly. With your example I can now get the value with the TryGetProperty method.

     

    $CompanyName = $null;

    $PropExist = $item.TryGetProperty($cmpName, [ref]$CompanyName);

    $CompanyName

     

    or

     

    $CompanyName = $PublicFolder.items[i].extendedproperties |select value

    $CompanyName.value

     

    Friday, January 28, 2011 6:36 PM
  • I'm trying to read a custom appointment form string value called "Type" that I created.

     

    foreach ($apApointment in $frCalendarResult.Items){
        $cmpName = new-object Microsoft.Exchange.WebServices.Data.ExtendedPropertyDefinition([Microsoft.Exchange.WebServices.Data.DefaultExtendedPropertySet]::PublicStrings,"Type",[Microsoft.Exchange.WebServices.Data.MapiPropertyType]::String);
        $psPropertySet = new-object Microsoft.Exchange.WebServices.Data.PropertySet([Microsoft.Exchange.WebServices.Data.BasePropertySet]::FirstClassProperties)
        $ivItemView.PropertySet = $cmpName
        $apApointment.load($psPropset)
        $apApointment.subject.ToString()
        $apApointment.Start.ToString()
        $apApointment.End.ToString()
        $apApointment.Organizer.ToString()
        $apApointment.Categories.ToString()
    }

    i get Property 'PropertySet' cannot be found on this object; make sure it exists and is settable.

    Where am I going wrong and how do i then reference the custom field after the load?

     

    Many Thanks 

    Tuesday, May 17, 2011 10:05 AM
  • Ben,

    Are you defining your itemview? e.g.  

    $ivItemView = new-object Microsoft.Exchange.WebServices.Data.ItemView(100)

    -Jan

    Friday, June 17, 2011 11:27 PM