Solved

Access VBA loop through new Outlook emails

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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
ms access query format every 30 mins 11 37
Query one and two years from today's date 10 38
Please Explain What Reading a Zip file Back In Means 11 59
Microsoft Access 2016 Bug? 9 41
AutoNumbers should increment automatically, without duplicates.  But sometimes something goes wrong, and the next AutoNumber value is a duplicate.  This article shows how to recover from this problem.
Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
Familiarize people with the process of utilizing SQL Server views from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Access…
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.

680 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