A Microsoft Outlook email forum. Outlook Banter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Outlook and VBA
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

How to program to export certain Outlook 2000 messages to Access 2000 database



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old December 19th 06, 07:16 PM posted to microsoft.public.outlook.program_vba
Oscar
external usenet poster
 
Posts: 3
Default How to program to export certain Outlook 2000 messages to Access 2000 database

I would like to export certain messages from my inbox to an Access
2000 database.

I do it manually by Files | Export, etc.

Please explain how to use the Outlook object model to do this via VB
or point me to an example on the web.

Thank you in advance.
Ads
  #2  
Old December 20th 06, 05:08 AM posted to microsoft.public.outlook.program_vba
Michael Bauer [MVP - Outlook]
external usenet poster
 
Posts: 1,885
Default How to program to export certain Outlook 2000 messages to Access 2000 database



This sample loops through the inbox:

Dim obj as Object
Dim Mail as Outlook.MailItem
Dim Folder as Outlook.Mapifolder
Dim Items as outlook.Items

Set Folder=Applcation.GetNamespace("Mapi").GetDefaultF older(olFolderInbox)
Set Item=Folder.Items
For Each obj in Items
If TypeOf obj is Outlook.MailItem then
Set Mail=obj
' go on here
Endif
Next

You can view the MailItem's properties with the Object Browser (F2). Switch
from All Libraries to Outlook and select the MailItem in the left pane.

This sample connects to an Access database with ADO. You need to add a
reference to 'Microsoft ActiveX Data Objects x' to your project:

Dim cn As ADODB.Connection
Dim rs As ADODB.Recordset

Set cn = New ADODB.Connection
With cn
.Provider = "Microsoft.Jet.OLEDB.4.0"
.ConnectionString = "D:\test.mdb"
.CursorLocation = adUseClient
.Mode = adModeShareDenyNone
.Open
End With

Set rs = New ADODB.Recordset
With rs
.CursorLocation = adUseClient
.CursorType = adOpenStatic
.LockType = adLockOptimistic
Set .ActiveConnection = cn
.Open ("select [field list] from [table]")
End With

rs.Close
cn.Close

You can use the connection's Execute command with the Insert or Update
statement to add/update single records (then the recordset isn't necessary),
or work with the recordset.

--
Viele Gruesse / Best regards
Michael Bauer - MVP Outlook
Keep your Outlook categories organized!
http://www.shareit.com/product.html?...4&languageid=1
(German: http://www.VBOffice.net/product.html?pub=6)

Am Tue, 19 Dec 2006 14:16:58 -0500 schrieb Oscar:

I would like to export certain messages from my inbox to an Access
2000 database.

I do it manually by Files | Export, etc.

Please explain how to use the Outlook object model to do this via VB
or point me to an example on the web.

Thank you in advance.

  #3  
Old December 20th 06, 10:56 PM posted to microsoft.public.outlook.program_vba
Oscar
external usenet poster
 
Posts: 3
Default How to program to export certain Outlook 2000 messages to Access 2000 database

I know how to do all of this already. The only place you address my
question is the line where you say "go on here"

I found a web site that says that the Outlook object model does not
allow access to the save as database file type command.

That website suggest automation of outlook with use of the SENDKEYS
command.

Thanks.

On Wed, 20 Dec 2006 06:08:40 +0100, "Michael Bauer [MVP - Outlook]"
wrote:



This sample loops through the inbox:

Dim obj as Object
Dim Mail as Outlook.MailItem
Dim Folder as Outlook.Mapifolder
Dim Items as outlook.Items

Set Folder=Applcation.GetNamespace("Mapi").GetDefaultF older(olFolderInbox)
Set Item=Folder.Items
For Each obj in Items
If TypeOf obj is Outlook.MailItem then
Set Mail=obj
' go on here
Endif
Next

You can view the MailItem's properties with the Object Browser (F2). Switch
from All Libraries to Outlook and select the MailItem in the left pane.

This sample connects to an Access database with ADO. You need to add a
reference to 'Microsoft ActiveX Data Objects x' to your project:

Dim cn As ADODB.Connection
Dim rs As ADODB.Recordset

Set cn = New ADODB.Connection
With cn
.Provider = "Microsoft.Jet.OLEDB.4.0"
.ConnectionString = "D:\test.mdb"
.CursorLocation = adUseClient
.Mode = adModeShareDenyNone
.Open
End With

Set rs = New ADODB.Recordset
With rs
.CursorLocation = adUseClient
.CursorType = adOpenStatic
.LockType = adLockOptimistic
Set .ActiveConnection = cn
.Open ("select [field list] from [table]")
End With

rs.Close
cn.Close

You can use the connection's Execute command with the Insert or Update
statement to add/update single records (then the recordset isn't necessary),
or work with the recordset.


  #4  
Old December 21st 06, 05:09 AM posted to microsoft.public.outlook.program_vba
Michael Bauer [MVP - Outlook]
external usenet poster
 
Posts: 1,885
Default How to program to export certain Outlook 2000 messages to Access 2000 database


How helpful a precise question is, isn't it?

I wouldn't recommend the use of SendKeys. It sends the commands to the
window with the focus, and you never know which one that is.

At the 'go on here' line simply read the item's properties and write them
into the recordset, or build a Insert statement.

--
Viele Gruesse / Best regards
Michael Bauer - MVP Outlook
Keep your Outlook categories organized!
http://www.shareit.com/product.html?...4&languageid=1
(German: http://www.VBOffice.net/product.html?pub=6)


Am Wed, 20 Dec 2006 17:56:19 -0500 schrieb Oscar:

I know how to do all of this already. The only place you address my
question is the line where you say "go on here"

I found a web site that says that the Outlook object model does not
allow access to the save as database file type command.

That website suggest automation of outlook with use of the SENDKEYS
command.

Thanks.

On Wed, 20 Dec 2006 06:08:40 +0100, "Michael Bauer [MVP - Outlook]"
wrote:



This sample loops through the inbox:

Dim obj as Object
Dim Mail as Outlook.MailItem
Dim Folder as Outlook.Mapifolder
Dim Items as outlook.Items

Set Folder=Applcation.GetNamespace("Mapi").GetDefaultF older(olFolderInbox)
Set Item=Folder.Items
For Each obj in Items
If TypeOf obj is Outlook.MailItem then
Set Mail=obj
' go on here
Endif
Next

You can view the MailItem's properties with the Object Browser (F2).

Switch
from All Libraries to Outlook and select the MailItem in the left pane.

This sample connects to an Access database with ADO. You need to add a
reference to 'Microsoft ActiveX Data Objects x' to your project:

Dim cn As ADODB.Connection
Dim rs As ADODB.Recordset

Set cn = New ADODB.Connection
With cn
.Provider = "Microsoft.Jet.OLEDB.4.0"
.ConnectionString = "D:\test.mdb"
.CursorLocation = adUseClient
.Mode = adModeShareDenyNone
.Open
End With

Set rs = New ADODB.Recordset
With rs
.CursorLocation = adUseClient
.CursorType = adOpenStatic
.LockType = adLockOptimistic
Set .ActiveConnection = cn
.Open ("select [field list] from [table]")
End With

rs.Close
cn.Close

You can use the connection's Execute command with the Insert or Update
statement to add/update single records (then the recordset isn't

necessary),
or work with the recordset.

  #5  
Old December 21st 06, 06:43 PM posted to microsoft.public.outlook.program_vba
Oscar
external usenet poster
 
Posts: 3
Default How to program to export certain Outlook 2000 messages to Access 2000 database

On Thu, 21 Dec 2006 06:09:10 +0100, "Michael Bauer [MVP - Outlook]"
wrote:

How helpful a precise question is, isn't it?


Maybe you didn't catch it but the precise question asked was:

"I do it manually by Files | Export, etc."

"Please explain how to use the Outlook object model to do this via VB
or point me to an example on the web."
 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I Import tables from Access 2000 into Outlook 2000? The Big O Outlook - Using Contacts 7 November 21st 06 02:02 PM
Help, please... Outlook 2000 cannot Export OR Archive emails. [email protected] Outlook - General Queries 1 February 4th 06 12:03 PM
Outlook 2000 export problem vradice Outlook - Using Contacts 0 February 3rd 06 03:39 PM
Outlook 2000 - Button to run Macro then open Database David C Outlook and VBA 1 January 25th 06 03:44 PM
Outlook 2000 Address Book Export/Import Mel Outlook - Using Contacts 3 January 12th 06 04:22 PM


All times are GMT +1. The time now is 03:36 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2025 Outlook Banter.
The comments are property of their posters.