Home  Fees/Services  Microsoft Access Templates  Tutorials  Access Download  Articles  Search  Contact  Privacy  Links

Access VBA Tutorial
   
Access Programming Examples & Code Samples

Read Outlook Email From Access Visual Basic Tutorials, Workarounds & Solutions for VB6
How To Read Email From Microsoft Access




VBA Tutorials:
Access to Google Earth
VB6 Age Calculation
Change Case VBA
VBA Email via Gmail
VBA Outlook Email
Read Email Access
RTF Report Email
Send Outlook Email Access
Calculate Running Sum
Concatenate Records
VBA Stock Quotes
VBA CreateQueryDef
Database Path Solution
Detail-Master Update
Field Validation VBA
Field Value New-Old
FindFirst Recordset
Get Version Number
VB6 Global Parameters
VBA Global Variables
Labels as Links
List Box Files List
VBA Mail Merge
OutputTo Crosstab
Sort Recordset Trick
VBA Recordset Filters
Reference Form Field
VBA Select Case
Transaction Processing

Visual Basic Function Examples


Read Email In To Microsoft Access Database

Reading email with Visual Basic API and create your own spam filter?  You can by reading Outlook emails from Microsoft Access.

There are three VB code samples demonstrating methods to communicate between Microsoft Access database and Microsoft Outlook for the purpose of sending and receiving emails programmatically using VBA:

MS Outlook provides a Visual Basic MAPI API to read email from Access VB and process attachments too.  In the example below we connect to the Microsoft Outlook inbox via the API and loop through each email message while storing parts of the email into a table:

Private Sub ReadInbox
Dim TempRst As DAO.Recordset
Dim rst As DAO.Recordset
Dim OlApp As Outlook.Application
Dim Inbox As Outlook.MAPIFolder
Dim InboxItems As Outlook.Items
Dim Mailobject As Object
Dim db As DAO.Database
Dim dealer As Integer
DoCmd.RunSQL "Delete * from tbl_outlooktemp"
Set db = CurrentDb

Set OlApp = CreateObject("Outlook.Application")
Set Inbox = OlApp.GetNamespace("Mapi").GetDefaultFolder(olFolderInbox)
Set TempRst = CurrentDb.OpenRecordset("tbl_OutlookTemp")
'
Set InboxItems = Inbox.Items
'
For Each Mailobject In InboxItems
    If Mailobject.UnRead Then
    With TempRst
       
        .AddNew
        !Subject = Mailobject.Subject
        !from = Mailobject.SenderName
        !To = Mailobject.To
        !Body = Mailobject.Body
        !DateSent = Mailobject.SentOn
        .Update
        Mailobject.UnRead = False
    End With
End If
Next

Set OlApp = Nothing
Set Inbox = Nothing
Set InboxItems = Nothing
Set Mailobject = Nothing
Set TempRst = Nothing

End Sub

To create your own spam filter you can use use several techniques.  Some examples are

  • Connect to the Outlook address book and check incoming addresses against your email address entries

  • Create a table of exclusion words for emails and use the Instr() function to scan for excluded words

  • Create a table of inclusion words to grab read email with these words.

To learn how to Send Outlook emails using Microsoft Access.








Have errors?  No doubt we can answer your question quickly and easily.  Simple questions get simple answers at no charge via email.




Popular Database Templates:

Personnel Agency Access Template Database

Rx/Prescription Assistance Plan Admin Template

Subscription Order Control Database Template




Contact Information

VBA runtime tips tricks fix solution

Access Visual Basic/VBA/VBScript/VB6 Tutorials
Visual Basic Error Fix & Problem Solutions