View Single Post
  #4  
Old May 23rd 06, 09:40 PM posted to microsoft.public.outlook.program_vba
Eric Legault [MVP - Outlook]
external usenet poster
 
Posts: 830
Default Export e-mail strings to database

There is very much possible. Below is an example of reading all e-mails in
the current folder and creating a new record in an Access database using DAO.
You can easily modify it to parse the message body to get the field/value
combinations you want, or switch to using ADO instead:

Sub WriteEmailToDatabase()
Dim objFolder As Outlook.MAPIFolder, objItems As Outlook.Items
Dim objEmail As Outlook.MailItem, objMessageObj As Object
Dim dbsThis As DAO.Database, rstThis As DAO.Recordset

Set dbsThis = DAO.OpenDatabase("C:\Documents and
Settings\elegault\Desktop\db1.mdb")
Set rstThis = dbsThis.OpenRecordset("Table1", dbOpenDynaset)

Set objFolder = Application.ActiveExplorer.CurrentFolder
Set objItems = objFolder.Items
For Each objMessageObj In objItems
If objMessageObj.Class = olMail Then
Set objEmail = objMessageObj

'SAVE TO ACCESS DATABASE
rstThis.AddNew
rstThis("Subject") = objEmail.Subject
rstThis("Body") = objEmail.Body
rstThis.UPdate
End If
Next
End Sub

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


" wrote:

I have a huge number of emails, which including text is sth like that:

name: tonia
occupation: unemployed
married: no
education: college

(this is just a sample which is similar to mine so you can understand
who thing goes)

Now all these mails i want to insert them into an MS Access database in
table with that kind of construction:

column1 -- name
column2 -- occupation
column3 -- married
column4 -- education

All i'm asking is if that huge number of mails, can be inserted into
the base, because the manually way it will take "years".

Well now I hope you could understand what kind of problem do i have!


Ads