Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Access and Outlook 1

Status
Not open for further replies.

Deb2004

Programmer
Oct 14, 2004
7
US
Is there a way to import the body of an Outlook email into an Access table? As email is in html, is it possible to capture data and link it to a table? I would appreciate help!
 
yes, but you'll have to use the Memo data type for that column. I've never done it in Access, but I have in SQL Server, using the Text data type.

IHTH

Ron Repp

If gray hair is a sign of wisdom, then I'm a genius.

My newest novel: Wooden Warriors
 
I've used the following code to loop through the inbox checking subjects (and testing them and then storing attachments but i haven't bothered to show that here) - I believe you can use .body and it should work the same
Have fun!

Dim oOutlook As Outlook.Application
Dim oNs As Outlook.NameSpace, oFldr As Outlook.MAPIFolder
Dim omessage As Object

Set oOutlook = New Outlook.Application
Set oNs = oOutlook.GetNamespace("MAPI")
Set oFldr = oNs.GetDefaultFolder(olFolderInbox)
' sets to outlook inbox
For Each omessage In oFldr.Items
mySubject = Trim(omessage.Subject)
MYBODY=OMESSAGE.BODY
' store wherever you like......
end for
 
Thank you so much for responding Ron and Piz! I appreciate your input. I am now having trouble with this:

Dim oOutlook As Outlook.Application
Dim oNs As Outlook.NameSpace, oFldr As Outlook.MAPIFolder
Dim omessage As Object

I have similar code, but it is not connecting Access to Outlook. It is connected in the live database, but I set up a simulation on my computer for testing purposes and it doesn't work. I still have hope that I can take fields from the email (html table) and save them to the database. Am I crazy?
 
does the code compile clean?
when you say "it doesn't work" what does it do?

If it's a compile problem then it's a library version difference maybe - in the code w1ndow go to
Tools - References - anything missing?
look for
Microsoft Outlook ??.? object library - the version number varies between windows versions and needs to be manually reset when you move the system as far as I can tell - I haven't found a way of automating the switch to correct version.
 
PicMac - you rock!!! Thank you! Now I can get to work transferring those fields. Wish me luck!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top