Outlook 2003 ADO connection string for use with VBScript...

M

M Scott S

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!
 
G

Guest

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.

--
Eric Legault (Outlook MVP, MCDBA, MCTS: Messaging & Collaboration)
Try Picture Attachments Wizard for Outlook:
http://www.collaborativeinnovations.ca
Blog: http://blogs.officezealot.com/legault/
 
M

M Scott S

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!
 
G

Guest

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/e...00-fb5c-42b5-9051-b5338b67a8dc.asp?frame=true

--
Eric Legault (Outlook MVP, MCDBA, MCTS: Messaging & Collaboration)
Try Picture Attachments Wizard for Outlook:
http://www.collaborativeinnovations.ca
Blog: http://blogs.officezealot.com/legault/
 
M

M Scott S

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...
 
M

M Scott S

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....

Eric Legault said:
Are you importing Outlook data into Access?

Does the computer running the code have an Outlook profile configured that
loads the .pst file?

--
Eric Legault (Outlook MVP, MCDBA, MCTS: Messaging & Collaboration)
Try Picture Attachments Wizard for Outlook:
http://www.collaborativeinnovations.ca
Blog: http://blogs.officezealot.com/legault/


M Scott S said:
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...


Eric Legault said:
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/e...00-fb5c-42b5-9051-b5338b67a8dc.asp?frame=true

--
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...

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!


in
message 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.

--
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?

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!


"Eric Legault [MVP - Outlook]" <[email protected]>
wrote
in
message 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?frame=true

--
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 Schaffernoth
Winnovative
Hudson, NY
(e-mail address removed)
 
G

Guest

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?

--
Eric Legault (Outlook MVP, MCDBA, MCTS: Messaging & Collaboration)
Try Picture Attachments Wizard for Outlook:
http://www.collaborativeinnovations.ca
Blog: http://blogs.officezealot.com/legault/


M Scott S said:
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....

Eric Legault said:
Are you importing Outlook data into Access?

Does the computer running the code have an Outlook profile configured that
loads the .pst file?

--
Eric Legault (Outlook MVP, MCDBA, MCTS: Messaging & Collaboration)
Try Picture Attachments Wizard for Outlook:
http://www.collaborativeinnovations.ca
Blog: http://blogs.officezealot.com/legault/


M Scott S said:
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...


message 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/e...00-fb5c-42b5-9051-b5338b67a8dc.asp?frame=true

--
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...

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!


in
message 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.

--
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?

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!


"Eric Legault [MVP - Outlook]" <[email protected]>
wrote
in
message 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?frame=true

--
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 Schaffernoth
Winnovative
Hudson, NY
(e-mail address removed)
 
M

M Scott S

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!
Eric Legault said:
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?

--
Eric Legault (Outlook MVP, MCDBA, MCTS: Messaging & Collaboration)
Try Picture Attachments Wizard for Outlook:
http://www.collaborativeinnovations.ca
Blog: http://blogs.officezealot.com/legault/


M Scott S said:
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....

Eric Legault said:
Are you importing Outlook data into Access?

Does the computer running the code have an Outlook profile configured
that
loads the .pst file?

--
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...?

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...


in
message 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/e...00-fb5c-42b5-9051-b5338b67a8dc.asp?frame=true

--
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...

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!


"Eric Legault [MVP - Outlook]" <[email protected]>
wrote
in
message 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.

--
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?

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!


"Eric Legault [MVP - Outlook]" <[email protected]>
wrote
in
message
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?frame=true

--
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 Schaffernoth
Winnovative
Hudson, NY
(e-mail address removed)
 
G

Guest

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

--
Eric Legault (Outlook MVP, MCDBA, MCTS: Messaging & Collaboration)
Try Picture Attachments Wizard for Outlook:
http://www.collaborativeinnovations.ca
Blog: http://blogs.officezealot.com/legault/


M Scott S said:
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!
Eric Legault said:
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?

--
Eric Legault (Outlook MVP, MCDBA, MCTS: Messaging & Collaboration)
Try Picture Attachments Wizard for Outlook:
http://www.collaborativeinnovations.ca
Blog: http://blogs.officezealot.com/legault/


M Scott S said:
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....

message Are you importing Outlook data into Access?

Does the computer running the code have an Outlook profile configured
that
loads the .pst file?

--
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...?

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...


in
message 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/e...00-fb5c-42b5-9051-b5338b67a8dc.asp?frame=true

--
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...

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!


"Eric Legault [MVP - Outlook]" <[email protected]>
wrote
in
message 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.

--
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?

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!


"Eric Legault [MVP - Outlook]" <[email protected]>
wrote
in
message
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?frame=true

--
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 Schaffernoth
Winnovative
Hudson, NY
(e-mail address removed)
 
S

Sue Mosher [MVP-Outlook]

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.
--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers


Eric Legault said:
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

--
Eric Legault (Outlook MVP, MCDBA, MCTS: Messaging & Collaboration)
Try Picture Attachments Wizard for Outlook:
http://www.collaborativeinnovations.ca
Blog: http://blogs.officezealot.com/legault/


M Scott S said:
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!
Eric Legault said:
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?

--
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...

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....

message Are you importing Outlook data into Access?

Does the computer running the code have an Outlook profile configured
that
loads the .pst file?

--
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...?

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...


in
message 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/e...00-fb5c-42b5-9051-b5338b67a8dc.asp?frame=true

--
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...

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!


"Eric Legault [MVP - Outlook]" <[email protected]>
wrote
in
message 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.

--
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?

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!


"Eric Legault [MVP - Outlook]" <[email protected]>
wrote
in
message
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?frame=true

--
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 Schaffernoth
Winnovative
Hudson, NY
(e-mail address removed)
 
M

M Scott S

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.
--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers


Eric Legault said:
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

--
Eric Legault (Outlook MVP, MCDBA, MCTS: Messaging & Collaboration)
Try Picture Attachments Wizard for Outlook:
http://www.collaborativeinnovations.ca
Blog: http://blogs.officezealot.com/legault/


M Scott S said:
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!
Eric Legault said:
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?

--
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...

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....

in
message Are you importing Outlook data into Access?

Does the computer running the code have an Outlook profile
configured
that
loads the .pst file?

--
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...?

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...


"Eric Legault [MVP - Outlook]" <[email protected]>
wrote
in
message 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/e...00-fb5c-42b5-9051-b5338b67a8dc.asp?frame=true

--
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...

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!


"Eric Legault [MVP - Outlook]" <[email protected]>
wrote
in
message
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.

--
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?

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!


"Eric Legault [MVP - Outlook]"
<[email protected]>
wrote
in
message
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?frame=true

--
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 Schaffernoth
Winnovative
Hudson, NY
(e-mail address removed)
 
S

Sue Mosher [MVP-Outlook]

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.

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers


M Scott S said:
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?


Eric Legault said:
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

:

Yes, the pst to be imported is in the default profile...

I need to import it into a CRM app called Saleslogix which support
VBscripting....

:

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
 

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