MS Office Forum / Outlook / Programming VBA / May 2006
Outlook 2003 ADO connection string for use with VBScript...
|
|
Thread rating:  |
M Scott S - 30 May 2006 15:55 GMT Can't seem to find this in technet....
Thanks!
 Signature M Scott Schaffernoth Winnovative Hudson, NY mscott@winnovative.com
Eric Legault [MVP - Outlook] - 30 May 2006 16:15 GMT ADO access to Outlook items is done server-side, using CDOEX with EXOLEDB.
See:
CDO and ADO: http://msdn.microsoft.com/library/en-us/e2k3/e2k3/_cdoex_about_cdo_and_ado.asp?f rame=true
 Signature Eric Legault (Outlook MVP, MCDBA, MCTS: Messaging & Collaboration) Try Picture Attachments Wizard for Outlook: http://www.collaborativeinnovations.ca Blog: http://blogs.officezealot.com/legault/
> Can't seem to find this in technet.... > > Thanks! M Scott S - 30 May 2006 16:19 GMT How am I using access to attach to the pst then?
No 'server' - just outlook and access and VBA in access.
However, I need to read the outlook data from another locally installed app that uses OLEDB and VB script so that I can run an export from the Outlook pst...
Thanks!
> ADO access to Outlook items is done server-side, using CDOEX with EXOLEDB. > [quoted text clipped - 6 lines] >> >> Thanks! Eric Legault [MVP - Outlook] - 30 May 2006 16:35 GMT Ah, I kind of wondered if you were using a linked table in Access.
Treat any linked tables in Access (pointing to an Outlook/Exchange source or not) as any other regular table regardless of connection mode (ADO, DAO, etc.).
E.g. Using ADO:
Dim rstThis As New ADODB.Recordset Dim conThis As New ADODB.Connection
conThis.Open "my connection string" rstThis.Open "Table1", conThis, adOpenDynamic, adLockOptimistic, adCmdTable
The connection string depends on whether you are using an ODBC connection or OLEDB provider.
However, if you have an existing linked table pointing to a .pst file and you need to setup a linked table for a different user (or edit the current linked table), then you need to use the Access Object Model to automate that. Then use ADO to work with the new linked table.
 Signature Eric Legault (Outlook MVP, MCDBA, MCTS: Messaging & Collaboration) Try Picture Attachments Wizard for Outlook: http://www.collaborativeinnovations.ca Blog: http://blogs.officezealot.com/legault/
> How am I using access to attach to the pst then? > [quoted text clipped - 16 lines] > >> > >> Thanks! M Scott S - 30 May 2006 16:44 GMT No, no linked table...
Just using Access as the testing conduit if you will, a place to run some VBA code, now that I am able to read my data, I need to convert my code over to an app that doesn't let me insert references the way access does, so I need to build the string manually and don't know the syntax...
Here is an example of what I have in Access...
Dim myOlApp As outlook.Application Dim myNameSpace As NameSpace Dim MyFolder As outlook.MAPIFolder Dim myContacts As Items Dim myAttachments As Items
Dim myItem As ContactItem Dim myAttm As Attachment Dim Item2 As Object
Set myOlApp = CreateObject("Outlook.Application") Set myNameSpace = myOlApp.GetNamespace("MAPI")
'pop a diag so the user can pick the folder - assumes that they will choose a contact folder, no code for not... Set MyFolder = myOlApp.Session.PickFolder Set myContacts = MyFolder.Items
'for each contact 'object' in the mycontacts collection... For Each Item2 In myContacts 'do something...
Next Item2
This is just the barebones to make it work, so no error handling, but it works and now I need to make happen in my VBScript app..
Thanks!
> Ah, I kind of wondered if you were using a linked table in Access. > [quoted text clipped - 45 lines] >> >> >> >> Thanks! Eric Legault [MVP - Outlook] - 30 May 2006 16:59 GMT Okay, if all you need is to port your VBA code to VBScript, get rid of any early-bound object declarations (just Dim X, not Dim X As This). There's other things to keep in mind as well:
Visual Basic for Applications Features Not In VBScript: http://msdn.microsoft.com/library/en-us/script56/html/90bf1300-fb5c-42b5-9051-b5 338b67a8dc.asp?frame=true
 Signature Eric Legault (Outlook MVP, MCDBA, MCTS: Messaging & Collaboration) Try Picture Attachments Wizard for Outlook: http://www.collaborativeinnovations.ca Blog: http://blogs.officezealot.com/legault/
> No, no linked table... > [quoted text clipped - 83 lines] > >> >> > >> >> Thanks! M Scott S - 30 May 2006 17:22 GMT I guess I do not understand how an program/script knows where the data comes from...?
I have added a reference to the Outlook object model in Access IDE...
I can't do that from the program in which I need to open outlook pst ...
So, I am under the impression I need a full connection string, no? And that it the crux of what I am asking...
> Okay, if all you need is to port your VBA code to VBScript, get rid of any > early-bound object declarations (just Dim X, not Dim X As This). There's [quoted text clipped - 98 lines] >> >> >> >> >> >> Thanks! Eric Legault [MVP - Outlook] - 30 May 2006 17:30 GMT Are you importing Outlook data into Access?
Does the computer running the code have an Outlook profile configured that loads the .pst file?
 Signature Eric Legault (Outlook MVP, MCDBA, MCTS: Messaging & Collaboration) Try Picture Attachments Wizard for Outlook: http://www.collaborativeinnovations.ca Blog: http://blogs.officezealot.com/legault/
> I guess I do not understand how an program/script knows where the data comes > from...? [quoted text clipped - 108 lines] > >> >> >> > >> >> >> Thanks! M Scott S - 30 May 2006 17:46 GMT Yes, the pst to be imported is in the default profile...
No, I don't really want to import into access, I could do that but that doesn't solve my problem...
I need to import it into a CRM app called Saleslogix which support VBscripting....
> Are you importing Outlook data into Access? > [quoted text clipped - 127 lines] >> >> >> >> >> >> >> >> Thanks! Eric Legault [MVP - Outlook] - 30 May 2006 18:04 GMT When you create or get an Outlook Application object, you are already using whatever .pst files are loaded in the default profile. Every loaded .pst is a top level collection of MAPIFolder objects in the NameSpace.Folders collection. So if there is two loaded .pst files, there will be two MAPIFolder objects in the NameSpace.Folders collection, with the MAPIFolder.Name property telling you how it is displayed in Outlook's folder list.
Am I getting closer to understanding your issue?
 Signature Eric Legault (Outlook MVP, MCDBA, MCTS: Messaging & Collaboration) Try Picture Attachments Wizard for Outlook: http://www.collaborativeinnovations.ca Blog: http://blogs.officezealot.com/legault/
> Yes, the pst to be imported is in the default profile... > [quoted text clipped - 135 lines] > >> >> >> >> > >> >> >> >> Thanks! M Scott S - 30 May 2006 18:12 GMT All I want to know is how to format a connection string to Outlook's datastore/database/namespace, whatever outlook calls it, so I can open up a connection to that data via ADO and read data from it...
Thanks!
> When you create or get an Outlook Application object, you are already > using [quoted text clipped - 167 lines] >> >> >> >> >> >> >> >> >> >> Thanks! Eric Legault [MVP - Outlook] - 30 May 2006 19:17 GMT Like I said in my first reply, you cannot access Outlook data using ADO, EXCEPT in server side code (like with Exchange Event Sinks) against Exchange data only. And that requires a different object model (CDOEX).
Outlook data is not in a relational database format. It's hierarchical and mainly folder based. Every Outlook folder is a MAPIFolder object that contains an Items collection with Item objects, which can be e-mail, Contacts, Tasks, etc.
This article has some good examples, and it's not specific to Outlook 2000:
Programming examples for referencing items and folders in Outlook 2000: http://support.microsoft.com/default.aspx?scid=kb;[LN];208520
 Signature Eric Legault (Outlook MVP, MCDBA, MCTS: Messaging & Collaboration) Try Picture Attachments Wizard for Outlook: http://www.collaborativeinnovations.ca Blog: http://blogs.officezealot.com/legault/
> All I want to know is how to format a connection string to Outlook's > datastore/database/namespace, whatever outlook calls it, so I can open up a [quoted text clipped - 172 lines] > >> >> >> >> >> > >> >> >> >> >> Thanks! Sue Mosher [MVP-Outlook] - 30 May 2006 19:55 GMT FWIW, it is possible to connect to Outlook data with ADO in a limited way -- see http://support.microsoft.com/?kbid=275262. For a PST file, you'd change the MAPILEVEL parameter to the display name of the file in Outlook's folder hierarchy.
But it has the same limitations as linked tables -- not even all of the most essential fields are exposed. That makes it useless, IMO. Direct access through the Outlook object model or Redemption Data Objects definitely is the way to go.
 Signature Sue Mosher, Outlook MVP Author of Configuring Microsoft Outlook 2003 http://www.turtleflock.com/olconfig/index.htm and Microsoft Outlook Programming - Jumpstart for Administrators, Power Users, and Developers http://www.outlookcode.com/jumpstart.aspx
> Like I said in my first reply, you cannot access Outlook data using ADO, > EXCEPT in server side code (like with Exchange Event Sinks) against Exchange [quoted text clipped - 186 lines] >> >> >> >> >> >> >> >> >> >> >> >> Thanks! M Scott S - 31 May 2006 22:00 GMT Ok, so let me, in my limited knowledge of CDO/Outlook, rephrase the question...
How would you format a connection in VBScript to connect to an outlook pst via CDO if said application hosting VBScript (and maybe this is for all VBScript apps, I don't know) does not have the facility to add a reference to the Outlook Object Model in the way you do in the access VBA IDE?
Make more sense?
FWIW, it is possible to connect to Outlook data with ADO in a limited way -- see http://support.microsoft.com/?kbid=275262. For a PST file, you'd change the MAPILEVEL parameter to the display name of the file in Outlook's folder hierarchy.
But it has the same limitations as linked tables -- not even all of the most essential fields are exposed. That makes it useless, IMO. Direct access through the Outlook object model or Redemption Data Objects definitely is the way to go.
 Signature Sue Mosher, Outlook MVP Author of Configuring Microsoft Outlook 2003 http://www.turtleflock.com/olconfig/index.htm and Microsoft Outlook Programming - Jumpstart for Administrators, Power Users, and Developers http://www.outlookcode.com/jumpstart.aspx
"Eric Legault [MVP - Outlook]" <elegaultZZZ@REMOVEZZZmvps.org> wrote in message news:57F6B08D-A3DA-497C-AE10-41B96CE95A4B@microsoft.com...
> Like I said in my first reply, you cannot access Outlook data using ADO, > EXCEPT in server side code (like with Exchange Event Sinks) against [quoted text clipped - 214 lines] >> >> >> >> >> >> >> >> >> >> >> >> Thanks! Sue Mosher [MVP-Outlook] - 31 May 2006 22:14 GMT Still probably the wrong question. CDO 1.21 doesn't use anything like database connections, and the only way CDO code can work with the data in a .pst file is if that file is already part of one of the user's saved mail profiles. In that case, you'd write your Session.Logon statement in your CDO code to load that profile.
But why would you want to use CDO, though, instead of Outlook objects? There is no guarantee that CDO will be installed on the user's machine. If you have high volume or need to access blocked properties, then I'd recommend you use Redemption Data Objects (RDO -- http://www.dimastr.com/redemption), not CDO.
It may help to think of Outlook's data structure as being more like Windows Explorers -- heterogeneous items (think: files) in folders, rather than homogeneous records in database tables.
See http://www.outlookcode.com/d/database.htm for some samples that you might find useful. If you're using VBScript, then you start with CreateObject("Outlook.Application") and cross your fingers that your anti-virus program doesn't block it.
 Signature Sue Mosher, Outlook MVP Author of Configuring Microsoft Outlook 2003 http://www.turtleflock.com/olconfig/index.htm and Microsoft Outlook Programming - Jumpstart for Administrators, Power Users, and Developers http://www.outlookcode.com/jumpstart.aspx
> Ok, so let me, in my limited knowledge of CDO/Outlook, rephrase the > question... [quoted text clipped - 38 lines] >>> >> >> I can't do that from the program in which I need to open outlook >>> >> >> pst
|
|
|