ADO Connection String Syntax

G

Guest

I borrowed some code I found referenced on here and came up with a version of
my own (listed below) to pull data from an Outlook folder into Access. I
don't really know what I'm doing though, and I'm struggling to find the ADO
connection string syntax to vary the code to fit what I want.

This code does pull in the specified data, but I want to access data in
other folders; e.g.: 'Mailbox - Vaughan Davies\Projects\Financials' or in a
public folder. I have tried:

"MAPILEVEL=Mailbox - Vaughan Davies|Projects|Financials;"
"MAPILEVEL=Mailbox - Vaughan Davies|Projects\Financials;"
"MAPILEVEL=Mailbox - Vaughan Davies\Projects\Financials;"
"MAPILEVEL=Mailbox - Vaughan Davies/Projects/Financials;"

... and every combination of "/", "|" & "\" but can't make it work.

** Can anyone point me to a reference on ADO connection string syntax that
might cover this aspect. **

** Also, the data returned seems to be that shown in the currrent view of
the folder. Can another view be specified in the connection string?**


Code listing follows:
________________________________________________
OpenExchange_Folder()
Dim ADOConn As ADODB.Connection
Dim ADORS As ADODB.Recordset
Dim strConn As String

Set ADOConn = New ADODB.Connection
Set ADORS = New ADODB.Recordset

With ADOConn
.Provider = "Microsoft.JET.OLEDB.4.0"
.ConnectionString = "Exchange 4.0;" _
& "MAPILEVEL=Mailbox - Vaughan Davies|Projects;" _
& "Profile=MS Exchange Settings;" _
& "TABLETYPE=0;DATABASE=C:\WINDOWS\TEMP;"
.Open
End With

With ADORS
.Open "Select * from Minutes", ADOConn, daOpenStatic, adLockReadOnly
.MoveFirst
Debug.Print ADORS(0).Name, ADORS(0).Value
Debug.Print ADORS(1).Name, ADORS(1).Value
Debug.Print ADORS(2).Name, ADORS(2).Value
Debug.Print ADORS(3).Name, ADORS(3).Value
Debug.Print ADORS(4).Name, ADORS(4).Value
Debug.Print ADORS(5).Name, ADORS(5).Value
Debug.Print ADORS(6).Name, ADORS(6).Value
Debug.Print ADORS(7).Name, ADORS(7).Value
Debug.Print ADORS(8).Name, ADORS(8).Value
Debug.Print ADORS(9).Name, ADORS(9).Value

.Close
End With

Set ADORS = Nothing
ADOConn.Close
Set ADOConn = Nothing
End Sub
 
G

Guest

Thanks for the reference Michael. It was a little technical for me, but
having read it several times its begining to sink in a little.

What I'm grappling with at the moment is getting the columns I want
transferred. It seems to be linked in some way to the current view on the
folder, but does not seem to be controllable. Has anyone got any examples of
linking to Outlook/Exchange via ADO? That would really help I think.

Many thanks in advance

Vaughan
 
G

Guest

Thanks for the pointer Michael.

I don't know how to do this, though. Can you (or anyone else), suggest
somewhere I can look for guidance on how to achieve it?

Thanks in advance

Vaughan
 
M

Michael Bauer

Hi Vaughan,

reading OL properties via the OOM:

First you need a reference on the folder with the items you want to
access. Sue provides a function that returns the folder by it´s path:
http://www.outlookcode.com/d/code/getfolder.htm

You can loop then through the items and access each item´s property:

Dim obj As Object
Dim oMail as Outlook.MailItem
For Each obj in YourFolder.Items
If TypeOf obj Is Outlook.MailItem
' Handle MailItems only, e.g.
Set oMail=obj
' Do s.th. with the item
Endif
Next

For connecting to a database via ADO please take a look at Sue´s site
again: http://www.outlookcode.com/d/database.htm
 
G

Guest

Thanks Michael

I have Sue's book, and I've had a bit of a play, and it seems I can do what
I want the way you suggested.

Many many thanks.

Vaughan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top