Platform SDK: Exchange 2000 Server

Create a Folder and Item

[This is preliminary documentation and subject to change.]

This example shows how to create a folder with an item and two custom properties on that item.

You create an item or folder by using the ADO Record object's Open method. The parameters should be as follows:

Parameter Value
Source The URL of the folder or item to be created
ActiveConnection A Connection object reference to use when binding.
Mode adModeReadWrite (3). Open the item read and write enabled.
CreateOptions AdCreateCollection constant (8192) to create a folder (collection).

-OR-

AdCreateNonCollection constant (0) to create an item that is not a folder.

-And-

adCreateOverwrite constant (67108864) to overwrite an existing item.

UserName Specify alternate credentials if needed.
Password Specify alternate credentials if needed.

[VBScript]
No code available

The following example creates an item in a user's mailbox, sets the content-class to be a message, sets some of the item's properties, and then binds a CDO Message object to the Record object.

[Visual Basic]
  Dim Rec    As New ADODB.Record
  Dim iMsg   As New CDO.Message
  Dim Rs     As New ADODB.Recordset
  Dim Conn   As New ADODB.Connection
  Dim Domain As String
  Dim UserAlias As String

  strURL = "file://./backofficestorage/" & _
           Domain  & _
           "/MBX/" & _
           UserAlias & _
           "/Drafts/121.eml"

  With Rec
    .Open strURL, , adModeReadWrite, adCreateOverwrite
    .Fields("DAV:contentclass") = "urn:content-classes:message"
    .Fields("urn:schemas:mailheader:subject") = "Message"
    .Fields("urn:schemas:mailheader:to")      = "user@microsoft.com"
    .Fields("urn:schemas:mailheader:from")    = "System Administrator"
    .Fields.Update
  End With
  With iMsg
    .Configuration.Fields(cdoSendUsingMethod) = cdoSendUsingExchange
    .Configuration.Fields.Update
    .DataSource.OpenObject Rec, "_Record"
    .From = "another@microsoft.com"
    .AddAttachment "m:\domain\public folders\docs\doc1.doc"
    .DataSource.Save
    .Send
  End With