add the code below to OUTLOOK vbe module.
this will take the current email being viewed,and add the info to your Db.
you MUST add the ADO connection in VBE references: menu, tools, references
checkmark: Microsoft ActiveX Data Objects X.X Library
user can click a button on Quick toolbar to run GrabCurrEdata()
Code:
Public Sub GrabCurrEdata()
Dim oInspector As Inspector
Dim oItem As MailItem
Dim vSubj, vFrom, vTo, vBody, vName
Set oInspector = Application.ActiveInspector
If oInspector Is Nothing Then
MsgBox "No active inspector"
Else
Set oItem = oInspector.CurrentItem
vName = oItem.Sender
vFrom = oItem.SenderEmailAddress
vSubj = oItem.Subject
vBody = oItem.Body
'vTo = oItem.Recipients(1)
'send info to db
Add1Rec vName, vFrom, vSubj, vBody
End If
Set oItem = Nothing
Set oInspector = Nothing
End Sub
Private Sub Add1Rec(pvName, pvEmail, pvSubj, pvBody)
Dim conn As ADODB.Connection
Dim cmd As New ADODB.Command
Dim sSql As String
Const kDB = "c:\folder\northwind.mdb"
on error goto errAdd
'NOTE: you must add the ADO reference in VBE menu: tools, references
'mark: Microsoft ActiveX Data Objects X.X Library
Set conn = CreateObject("ADODB.Connection")
conn.Provider = "Microsoft.Jet.OLEDB.4.0"
conn.Open kDB
sSql = "insert into table (Name, Email, Subj, Body) values ('" & pvName & "','" & pvEmail & "','" & pvSubj & "','" & pvBody & "');"
With cmd
.CommandText = sSql
.CommandType = adCmdText
.ActiveConnection = conn.ConnectionString
.Execute
End With
Endit:
conn.Close
Set rst = Nothing
Set conn = Nothing
Exit Sub
errAdd:
MsgBox Err.Description
Resume Endit
End Sub