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!
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.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.