Connection with an SQL Server 2005 database

  • Thread starter Thread starter RosH
  • Start date Start date
R

RosH

I would like to create a macro when triggered at the definition of a
rule in Outlook would read the properties of the new email and update
a SQL Server 2005 database through a database connection. For example
I would like to store and append all the sender names and the subject
field of ruled out emails into a database which is already defined.
Which classes should I be using to achieve this and what will be the
procedure?

Thank you in advance.
 
Thank you very much Eric for the references. I was able to build the
code myself. But unfortunately errors keep on following me. I have
included the code and the error below. I would appreciate you to
comment on it.

Error-----------------
Multiple-Step OLE DB operation generated errors. Check each OLE DB
status value, if available. No work was done.

Code----------------------

Sub RosHConnectSQL()
Dim Dbcon As New ADODB.Connection
Dim Dbcom As New ADODB.Command
Dim DbRs As New ADODB.Recordset

Dbcon.ConnectionString = "Data Source=.
\SQLEXPRESS;AttachDbFilename=""C:\Documents and Settings\Administrator
\My Documents\Website.mdf"";Integrated Security=True;Connect
Timeout=30;User Instance=True"

Dbcon.Open
Dbcom.ActiveConnection = Dbcon
Dbcom.CommandText = "Select StatusID from Status"
Set DbRs = Dbcom.Execute
MsgBox DbRs(0)

DbRs.Close
Dbcon.Close


End Sub
 
I'd be more than happy to help you with Outlook related questions, but for
SQL stuff please post in the appropriate newsgroup. I don't see anything
wrong with your code that's immediately apparent.
 
Back
Top