Solved

Access VBA loop through new Outlook emails

Posted on 2011-02-27
3
590 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article is a continuation or rather an extension from Cascading Combos (http://www.experts-exchange.com/A_5949.html) and builds on examples developed in detail there. It should be understandable alone, but I recommend reading the previous artic…
In the previous article, Using a Critera Form to Filter Records (http://www.experts-exchange.com/A_6069.html), the form was basically a data container storing user input, which queries and other database objects could read. The form had to remain op…
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

840 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