Murray Brown
asked on
Access or Excel VBA loop through Outlook emails
Hi
What Access or Excel VBA code would I use to loop through my Outlook inbox and find a certain subject in new emails, then save attachments to a specific folder?
What Access or Excel VBA code would I use to loop through my Outlook inbox and find a certain subject in new emails, then save attachments to a specific folder?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Dim olkApp As Outlook.Application, olkNS As Outlook.NameSpace, olkFolder As Outlook.MAPIFolder, olkMessage As Outlook.MailItem, strSubject As String, strBody As String
StartReadinbox:
COunt = 0
Set objApp = CreateObject("Outlook.Application")
Set objNS = objApp.GetNamespace("MAPI")
rem Inbox incoming email address
Set inbox = objApp.GetNamespace("Mapi").Folders("wekeelanotes@campwekeela.com").Folders("InBox")
For Each objMessage In inbox.Items
If objMessage.UnRead = True Then
strSubject = objMessage.Subject 'subject
strBody = objMessage.Body 'body of message
strsender = objMessage.SenderEmailAddress 'sender
GoSub 'Process Email Data
objMessage.Delete
COunt = COunt + 1
End If
Next
Exit Sub
end sub