This sample loops through the inbox:
Dim obj as Object
Dim Mail as Outlook.MailItem
Dim Folder as Outlook.Mapifolder
Dim Items as outlook.Items
Set Folder=Applcation.GetNamespace("Mapi").GetDefaultFolder(olFolderInbox)
Set Item=Folder.Items
For Each obj in Items
If TypeOf obj is Outlook.MailItem then
Set Mail=obj
' go on here
Endif
Next
You can view the MailItem's properties with the Object Browser (F2). Switch
from <All Libraries> to Outlook and select the MailItem in the left pane.
This sample connects to an Access database with ADO. You need to add a
reference to 'Microsoft ActiveX Data Objects x' to your project:
Dim cn As ADODB.Connection
Dim rs As ADODB.Recordset
Set cn = New ADODB.Connection
With cn
.Provider = "Microsoft.Jet.OLEDB.4.0"
.ConnectionString = "D:\test.mdb"
.CursorLocation = adUseClient
.Mode = adModeShareDenyNone
.Open
End With
Set rs = New ADODB.Recordset
With rs
.CursorLocation = adUseClient
.CursorType = adOpenStatic
.LockType = adLockOptimistic
Set .ActiveConnection = cn
.Open ("select [field list] from
")
End With
rs.Close
cn.Close
You can use the connection's Execute command with the Insert or Update
statement to add/update single records (then the recordset isn't necessary),
or work with the recordset.