How to update a MAPI PT_BINARY value with VBScript RRS feed

  • Question


    I'm still living in the late 20th century.


    I can read a PT_BINARY value using CDO 1.2.1 and it is converted to a Hex string.


    I am now trying to update a PT_BINARY value, and get E_INVALID_ARG (when I do objItem.Update true) after setting the value to a hex string. (objItem.Fields.Add (lngProperty,strValue))

    I tried converting strValue to a byte array, but got error MAPI_E_NO_SUPPORT at the .Update


    I'm not set on CDO1.2.1 but would much prefer VBScript to VB.NET for this application.


    Any suggestions?


    Thanks very much in advance.

    Saturday, May 17, 2008 1:58 PM


  • Stephen,


    This code works for me - see if you can pick the bones out of it or spot anything useful. I use it to set a MAPI Object property I call UID because its where outlook puts the UID from an iCal file.


    Sub SetUID(UID)
    ' UID passed is a simple DHS Booking reference (string)- we have to convert it to a string of Hex character values and
    ' add the standard preamble to make a valid Outlook UID and then insert it into the extended MAPI Object connected
    ' to our appointment
     Dim objSession
     Dim objAppt
     Dim propSetD
     Dim objFields
     Dim objUID
     Dim hexUID
     Dim i
     'If EntryId is blank we can't set the UID (shouldn't normally happen)
     if len(item.EntryID) = 0 then exit Sub
     'Start with the standard preamble
     'Now add the provided string
     for i = 1 to len(UID)
      hexUID = hexUID & cstr(hex(asc(mid(UID,i,1))))
     'Terminate the UID
     hexUID=hexUID & "00"
     'Now insert it into the extended MAPI object
     Set objSession = CreateObject("MAPI.Session")
     objSession.Logon "", "", False, False
     Set objAppt = objSession.GetMessage(Item.EntryID)
     propSet = "90DAD86E0B451B1098DA00AA003F1305"
     Set objFields = objAppt.Fields
     Set objUID=objFields.Item("0x0003", propSet)
     objUID.Value = hexUID
     objAppt.Update true,true
     'Tidy up
    End Sub


    Thursday, June 5, 2008 8:47 AM