Question VBA: Email from Outook express into table (1 Viewer)

DanJames

Registered User.
Local time
Today, 04:20
Joined
Sep 3, 2009
Messages
78
Hi, I would like to have the code to import any email from a specific person say (dan_james11@me.com) and also (johnsmith@me.com) to a microsoft access table called tblEmailImport.

I would have a table with To, From, CC, Subject, Body, Title.. ect.

I've heared this can be done somehow, hopefully with VBA code.

Thanks alot, Dan.
 

HiTechCoach

Well-known member
Local time
Today, 06:20
Joined
Mar 6, 2006
Messages
4,357
AFAIK, Outlook Express does not support Automation like with full Outlook.

You might have to manually export the data into a format that Access can read. You can then write VBA code to parse the file.
 

DanJames

Registered User.
Local time
Today, 04:20
Joined
Sep 3, 2009
Messages
78
And how would I do that?
 

ajetrumpet

Banned
Local time
Today, 06:20
Joined
Jun 22, 2007
Messages
5,638
And how would I do that?

togo with boyd's response, I don't think express support vba. how about exporting the email message to a text file, then write a procedure to import all the text files you made and throw the parsed sections into the fields you want?

is there an export option in outlook express?
 

Mike375

Registered User.
Local time
Today, 22:20
Joined
Aug 28, 2008
Messages
2,548
This might get you started. The code below is importing from an Outlook folder called Bounces to Excel. I think you can import emails from Outlook Express to Outlook.

This code imports all the emails in the folder and it is simple to have the Excel import to Access. It is all done in one go. I have them come into because I also need it in Excel and it also works for someone who does not have Access.

For exactly what you want you would need to transfer the emails in question from the inbox to another folder. You could probaly make something in Outlook so that when you clicked on an email it would copy it to another folder. Outlook is programmed in a manner similar to Excel and Word, that is, it has macros that are containers for VBA.

Dim myOlApp As Outlook.Application

Set myOlApp = CreateObject("Outlook.Application")
Set myNameSpace = myOlApp.GetNamespace("MAPI")
Set myfolders = myNameSpace.Folders

n = 1
Do Until myfolders.Item(n) = "Personal Folders"
n = n + 1
Loop

Set myfolder = myfolders.Item(n)
Set myfolder2 = myfolder.Folders("Bounces")

c = 1
n = 1
For Each Item In myfolder2.Items
itsj = Item.Subject
itsn = Item.To
itbo = Item.SenderEmailAddress
itbz = Item.CreationTime
itbx = Item.Body

Cells(n, c) = itsn
Cells(n, c + 1) = itsj
Cells(n, c + 2) = itbo
Cells(n, c + 3) = itbz
Cells(n, c + 4) = itbx

n = n + 1
Next Item
 

DanJames

Registered User.
Local time
Today, 04:20
Joined
Sep 3, 2009
Messages
78
So as Outlook and Outlook express are different email programs. Would Outlook import to access? Is outlook better for my situation?
 

Mike375

Registered User.
Local time
Today, 22:20
Joined
Aug 28, 2008
Messages
2,548
So as Outlook and Outlook express are different email programs. Would Outlook import to access? Is outlook better for my situation?

Outlook is part of Microsoft Office just like Access, Excel and Word. You can have Outlook import your emails from Outlook Express and that would be the first job. I am sure there is someone in the world who can do what your want with Outlook Express but you will spend the rest of your finding him:D

I have given you a start with the code I posted that brings the email details into Excel. You will find any help you require along the way is virtually guaranteed to come from someone using Outlook.

Here is an Outlook forum

http://www.outlookcode.com/

From memory it is run by a lady (Sue??) who is a Microsoft Valued Professional for Outlook.
 

HiTechCoach

Well-known member
Local time
Today, 06:20
Joined
Mar 6, 2006
Messages
4,357
So as Outlook and Outlook express are different email programs. Would Outlook import to access? Is outlook better for my situation?

if you are going to be import you email on a regular cycle, then Outlook would be a better choice since Access can control Oulook through VBA automation.

It is possible to migrate you express data to Outlook
 

DanJames

Registered User.
Local time
Today, 04:20
Joined
Sep 3, 2009
Messages
78
This might get you started. The code below is importing from an Outlook folder called Bounces to Excel. I think you can import emails from Outlook Express to Outlook.

This code imports all the emails in the folder and it is simple to have the Excel import to Access. It is all done in one go. I have them come into because I also need it in Excel and it also works for someone who does not have Access.

For exactly what you want you would need to transfer the emails in question from the inbox to another folder. You could probaly make something in Outlook so that when you clicked on an email it would copy it to another folder. Outlook is programmed in a manner similar to Excel and Word, that is, it has macros that are containers for VBA.

Dim myOlApp As Outlook.Application

Set myOlApp = CreateObject("Outlook.Application")
Set myNameSpace = myOlApp.GetNamespace("MAPI")
Set myfolders = myNameSpace.Folders

n = 1
Do Until myfolders.Item(n) = "Personal Folders"
n = n + 1
Loop

Set myfolder = myfolders.Item(n)
Set myfolder2 = myfolder.Folders("Bounces")

c = 1
n = 1
For Each Item In myfolder2.Items
itsj = Item.Subject
itsn = Item.To
itbo = Item.SenderEmailAddress
itbz = Item.CreationTime
itbx = Item.Body

Cells(n, c) = itsn
Cells(n, c + 1) = itsj
Cells(n, c + 2) = itbo
Cells(n, c + 3) = itbz
Cells(n, c + 4) = itbx

n = n + 1
Next Item


Where do i put this vba code? Access?
 

DanJames

Registered User.
Local time
Today, 04:20
Joined
Sep 3, 2009
Messages
78
I manually know how to export emails from ms outlook. However I do not have the code for this for ms access. Any Ideas?
 

Mike375

Registered User.
Local time
Today, 22:20
Joined
Aug 28, 2008
Messages
2,548
Where do i put this vba code? Access?

And Excel Macro that is run from Access. And of course it can be run from Excel. The normal Outlook security box will open when you open Outlook from another program.
 

Users who are viewing this thread

Top Bottom