Knowing how to read e-mail through a Microsoft Access application using Visual Basic for Applications (VBA) can help you make applications more user-friendly. Microsoft Access is a relational database management system often used for small, local databases. Outlook is an e-mail management system included in the Microsoft Office suite. VBA is a computer programming language. In a few steps, you can learn and write VBA code to read Outlook e-mail items.
- Skill level:
Other People Are Reading
Open Microsoft Access 2007. Click "Database Tools" and select "Visual Basic." Select the "Tools" menu and click "References." Check the box next to "Microsoft Outlook (version number) Object Library." Click "OK."
Copy and paste the code below into your new module. The code will read the "Inbox" folder in Microsoft Outlook e-mail and display the subject and body through a message box.
Private Sub ReadOutlookMail()
Set otlkApp = CreateObject("Outlook.Application")
Set MAPISpace = otlkApp.GetNamespace("MAPI")
Set otlkFolder = MAPISpace.GetDefaultFolder(olFolderInbox)
For Each MailItem In otlkFolder.Items
MsgBox "Subject:" & MailItem.Subject & "Body:" & MailItem.body
Press "F5" to run your "ReadOutlookMail" subroutine.
- 20 of the funniest online reviews ever
- 14 Biggest lies people tell in online dating sites
- Hilarious things Google thinks you're trying to search for