Module Module1
Sub Main()
Dim oCn As ADODB.Connection = New ADODB.Connection()
Dim oRc As ADODB.Record = New ADODB.Record()
Dim oFields As ADODB.Fields
Dim oField As ADODB.Field
' TODO: Replace with your message URL.
Dim sItemUrl As String
sItemUrl = "http://<ExchServer>/Exchange/<UserAlias>/Inbox/Test.eml"
oCn.Provider = "exoledb.datasource"
oCn.Open(sItemUrl, "", "", -1)
If oCn.State = 1 Then
Console.WriteLine("Good Connection")
Else
Console.WriteLine("Bad Connection")
Return
End If
oRc.Open(sItemUrl, oCn, _
ADODB.ConnectModeEnum.adModeReadWrite, _
ADODB.RecordCreateOptionsEnum.adFailIfNotExists, _
ADODB.RecordOpenOptionsEnum.adOpenSource, _
"", "")
If oRc.State = ADODB.ObjectStateEnum.adStateOpen Then
Console.WriteLine("Record open is a success.")
Else
Console.WriteLine("Record open has failed.")
Return
End If
oFields = oRc.Fields
' List the fields.
Dim i As Integer
For i = 0 To oFields.Count - 1
oField = oFields.Item(i)
Console.WriteLine("{0} : {1}", oField.Name, oField.Value)
Next
' Modify the Subject property and the Read property by using the Fields object.
oFields.Item("urn:schemas:mailheader:subject").Value = "Modified Subject"
oFields.Item("urn:schemas:httpmail:read").Value = True
oFields.Update()
oRc.Close()
oCn.Close()
'iMsg = Nothing
oCn = Nothing
oRc = Nothing
oFields = Nothing
oField = Nothing
End Sub
End Module