Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Access VBA loop through new Outlook emails

Posted on 2011-02-27
3
Medium Priority
?
603 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:Murray Brown
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 2000 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:Murray Brown
ID: 34997454
Thanks very much
0

Featured Post

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

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

Microsoft Access is a place to store data within tables and represent this stored data using multiple database objects such as in form of macros, forms, reports, etc. After a MS Access database is created there is need to improve the performance and…
Explore the ways to Unlock VBA Project Password Excel 2010 & 2013 documents. Go through the article and perform the steps carefully to remove VBA Excel .xls file.
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
Suggested Courses

971 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