Platform SDK: Exchange 2000 Server

Setting and Retrieving Custom Properties

[This is preliminary documentation and subject to change.]

This example demonstrates setting properties on items in the Web Store. Note that the Web Store schema does not define the properties. These custom properties are used and defined by this application.

[VBScript]
Dim Rec
Dim DomainName
Dim strSource
Dim strNewRec
Dim flds
Dim strSchemaName
Dim strF1
Dim strF2

Const adCreateNonCollection = 0
Const adCreateOverwrite = 67108864
Const adModeReadWrite = 3
Const adCurrency = 6
Const adDate = 7


Set Rec = CreateObject("ADODB.Record")

'specify your own domain
DomainName = "microsoft.com"

'construct the base for naming the cutom properties
strSchemaName = "http://" & DomainName & "/schema/"

'specify a URL for a new item
strNewRec = "public folders/test/proptest3.txt"

strSource = "file://./backofficestorage/" & DomainName & "/" & strNewRec

'Create the item, and specify content-class
Rec.Open strSource, , adModeReadWrite, (adCreateNonCollection Or adCreateOverwrite)
Rec.Fields("urn:schemas:mailheader:content-class").Value = "urn:schemas:content-classes:item"
Rec.Fields.Update

'Add a couple of custom properties to the item
Set flds = Rec.Fields

'append the custom properties
flds.Append strSchemaName & "Amount", adCurrency, , , 50000
flds.Append strSchemaName & "Date", adDate, , , Date

Flds.Update
Rec.Close

'Open the record and test the custom properties
Rec.Open strSource

'names of the properties
strF1 = strSchemaName & "Amount"
strF2 = strSchemaName & "Date"

'write the custom property values
Response.Write "Amount: " & Rec.Fields(strF1).Value & "</p>"
Response.Write "Date: " & Rec.Fields(strF2).Value & "</p>"

Rec.Close

This example shows how to set custom properties.

[Visual Basic]
    Dim strURI As String
    strURI = "file://./backofficestorage/" & _
            Environ("USERDNSDOMAIN") & _
            "/Public Folders/mytestfolder/"
                       
  
    Dim Rec As New Record
    Rec.Open strURI, , adModeReadWrite, (adCreateOverwrite Or adCreateCollection)

    Dim doc As New Record

    doc.Open _
                "item1.txt", _
                Rec.ActiveConnection, _
                adModeReadWrite, _
                (adCreateNonCollection Or adOpenIfExists)

    Dim Flds As Fields
    Set Flds = doc.Fields
  With Flds
    .Append "urn:schemas-unique-tld:modified",     adDate, , , Now
    .Append "urn:schemas-unique-tld:status",       adBSTR, , , "Behind Schedule"
    .Append "urn:schemas-unique-tld:author",       adBSTR, , , "Paul West"
    .Append "urn:schemas-unique-tld:author-email", adBSTR, , , """Paul west"" <pw@somewhere.exchange.microsoft.com>"
    .Append "urn:schemas-unique-tld:editor",       adBSTR, , , "Wendy Wheeler"
    .Append "urn:schemas-unique-tld:editor-email", adBSTR, , , """Wendy Wheeler"" <ww@somewhere.exchange.microsoft.com>"
    .Update
  End With

' This example shows how to retrieve custom property values just set in the previous example.

    Dim strURI As String
    strURI = "file://./backofficestorage/" & _
            Environ("USERDNSDOMAIN") & _
            "/Public Folders/mytestfolder/"
                       
  
    Dim Rec As New Record
    Rec.Open strURI, , adModeReadWrite

    Dim doc As New Record

    doc.Open _
                strURI + "item1.txt", _
                Rec.ActiveConnection, _
                adModeReadWrite

    Dim Flds As Fields
    Set Flds = doc.Fields
    Dim Props(10) As Variant
    Props(1) = " urn:schemas-unique-tld:modified"
    Props(2) = " urn:schemas-unique-tld:status"
    Props(3) = " urn:schemas-unique-tld:author"
    Props(4) = " urn:schemas-unique-tld:author-email"
    Props(5) = " urn:schemas-unique-tld:editor"
    Props(6) = " urn:schemas-unique-tld:editor-email"
    For i = 1 To 6
      Debug.Print Props(i) & vbCrLf
      Debug.Print Flds(Props(i))
    Next i