Free Lessons
Courses
Seminars
TechHelp
Fast Tips
Templates
Topic Index
Forum
ABCD
 
Home   Courses   TechHelp   Forums   Help   Contact   Merch   Join   Order   Logon  
 
Back to Access Developer Forum    Comments List
Upload Images   @Reply   Bookmark    Link   Email   Next Unseen 
How to Push Emails From Outlook to Access Database
Richard Rost 
          
14 months ago
Microsoft has announced that classic Outlook is on the way out. Because of that, I decided not to go forward with a full video tutorial for this method. However, if you are still using classic Outlook and want a way to push incoming email messages into your Access database, this method might be helpful.

Most users try to pull email into Access from Outlook. That works, but it often triggers security warnings or prompts. This approach flips that around. Instead of Access trying to pull data out of Outlook, Outlook pushes the data into your Access database. This can eliminate a lot of the usual security issues and give you more control over how email data is handled.

Requirements:

- Gmail (IMAP enabled)
- Classic Outlook with macro support
- Microsoft Access

Step 1: Enable Macros and Configure Outlook

First, make sure Gmail is configured with IMAP folders and set as your default PST file in Outlook.

Then enable macros in Outlook:
File > Options > Trust Center > Trust Center Settings > Macro Settings  
Set to Enable All Macros (only if you're sure nobody else can access your system)  
Enable the Developer ribbon  

Note: This method only works with your default inbox. If you use additional PST files, more configuration is needed.

Step 2: Set Up Code in ThisOutlookSession

Open the VBA editor in Outlook (Alt + F11)  
Expand the Project Explorer and locate ThisOutlookSession

Insert this code to run when Outlook starts:

CodeDim oNS As Outlook.NameSpace
Dim WithEvents oItems As Outlook.Items

Private Sub Application_Startup()
    Dim oInbox As Outlook.Folder
    Set oNS = Application.GetNamespace("MAPI")
    Set oInbox = oNS.GetDefaultFolder(olFolderInbox)
    Set oItems = oInbox.Items
    Set oInbox = Nothing
End Sub


You can test this by adding a simple message box:

CodeMsgBox "Startup!"


Step 3: Add the ItemAdd Handler

Still in ThisOutlookSession, add this code:

CodePrivate Sub oItems_ItemAdd(ByVal Item As Object)
    ProcessMailItem Item
    Set Item = Nothing
End Sub


You can trigger this by dragging an email into your inbox from another folder like Drafts or Trash.

Step 4: Create the Processing Code in a Standard Module

In the VBA editor, go to Insert > Module

Add the following code and make sure you reference the Microsoft Office Access database engine library:

CodePublic Sub ProcessMailItem(Item As MailItem)
    Dim db As Database, rs As Recordset
    On Error GoTo EndOfSub

    Set db = OpenDatabase("Z:\OutlookMailTemp.accdb")
    Set rs = db.OpenRecordset("OutlookT")

    rs.AddNew
    rs!FromName = Item.SenderName
    rs!Email = Item.SenderEmailAddress
    rs!Subject = Item.Subject
    rs!Body = Item.Body
    rs!EmailDate = Item.SentOn
    rs!EmailTo = Item.To
    rs.Update

    rs.Close
    db.Close
    Set rs = Nothing
    Set db = Nothing

    Item.Delete

EndOfSub:
    ' You can also capture other fields here:
    ' Item.BodyFormat, Item.Sender, Item.CC, Item.ReceivedTime
    ' Attachments can be extracted too, but that is outside the scope of this tutorial
End Sub


Step 5: Link Access to the Temporary Table

In your main Access database, link to Z:\OutlookMailTemp.accdb  
Create a routine to copy the records from OutlookT into your local table  
You can then use your existing forms and queries to manage the messages

Conclusion

This method avoids most of the common Outlook security warnings by using Outlook itself to push messages into your database. It is a clean and efficient way to move emails into Access without the hassle. I am not making a full video tutorial on this due to Microsoft's upcoming changes to Outlook, but this code should still be helpful for anyone using the classic version.

This thread is now CLOSED. If you wish to comment, start a NEW discussion in Access Developer Forum.
 

Next Unseen

 
New Feature: Comment Live View
 
 

The following is a paid advertisement
Computer Learning Zone is not responsible for any content shown or offers made by these ads.
 

Learn
 
Access - index
Excel - index
Word - index
Windows - index
PowerPoint - index
Photoshop - index
Visual Basic - index
ASP - index
Seminars
More...
Customers
 
Login
My Account
My Courses
Lost Password
Memberships
Student Databases
Change Email
Info
 
Latest News
New Releases
User Forums
Topic Glossary
Tips & Tricks
Search The Site
Code Vault
Collapse Menus
Help
 
Customer Support
Web Site Tour
FAQs
TechHelp
Consulting Services
About
 
Background
Testimonials
Jobs
Affiliate Program
Richard Rost
Free Lessons
Mailing List
PCResale.NET
Order
 
Video Tutorials
Handbooks
Memberships
Learning Connection
Idiot's Guide to Excel
Volume Discounts
Payment Info
Shipping
Terms of Sale
Contact
 
Contact Info
Support Policy
Mailing Address
Phone Number
Fax Number
Course Survey
Email Richard
[email protected]
Blog RSS Feed    YouTube Channel

LinkedIn
Copyright 2026 by Computer Learning Zone, Amicron, and Richard Rost. All Rights Reserved. Current Time: 6/22/2026 9:27:14 PM. PLT: 0s