Solved

Access VBA loop through new Outlook emails

Posted on 2011-02-27
3
586 Views
Last Modified: 2012-05-11
Hi
What VBA code would I use to loop through the new emails
in my Outlook Inbox and look for a string match in the Outlook header
0
Comment
Question by:murbro
3 Comments
 
LVL 6

Expert Comment

by:TinTombStone
ID: 34992196
If you want to do something in Outlook from Access chesck out

http://www.helenfeddema.com/

0
 
LVL 10

Accepted Solution

by:
conagraman earned 500 total points
ID: 34996785
murbro

here is some code that searches the outlook inbox and then lists the subject line in a list box. i also attatched a sample database for you to look at.

'------needs a reference to Microsoft Outlook 12.0 object library
On Error Resume Next

Dim Olook As Outlook.Application
Dim oNs As Outlook.NameSpace
Dim oFldr As Outlook.MAPIFolder
Dim OMail As Outlook.MailItem
Dim LookFor As String


Set Olook = New Outlook.Application
Set oNs = Olook.GetNamespace("MAPI")
Set oFldr = oNs.GetDefaultFolder(olFolderInbox)



LookFor = "a"
Me.ListBox.RowSource = ""
For Each OMail In oFldr.Items
        With OMail
          If InStr(.Subject, LookFor) Then
          Me.List1.AddItem (OMail.Subject)
          End If
        End With
Next OMail
         
    Set OMail = Nothing
    Set oFldr = Nothing
    Set oNs = Nothing
    Set Olook = Nothing
   
outlookInbox.accdb
0
 

Author Closing Comment

by:murbro
ID: 34997454
Thanks very much
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

When you are entering numbers in a speadsheet, and don't remember what 6×7 is, you just type “=6*7" instead. It works in every cell! This is not so in Access. To enter the elusive 42 in a text box, you have to find a calculator, and then copy the re…
Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now