I am working to automate a recurring task.
Search an e-mail inbox (not the primary Outlook account) for items with a subject that contains: "Acting / Additional".
Sub SrchRF4AAABonuses()
Dim myOlApp As New Outlook.Application
Dim objNamespace As Outlook.NameSpace
Dim objFolder As Outlook.MAPIFolder
Dim filteredItems As Outlook.Items
Dim itm As Object
Dim Found As Boolean
Dim strFilter As String
Set objNamespace = myOlApp.GetNamespace("MAPI")
Set objFolder = objNamespace.GetDefaultFolder(olFolderInbox)
strFilter = "@SQL=" & Chr(34) & "urn:schemas:httpmail:subject" & Chr(34) & " like '%Acting / Additional%'"
Set filteredItems = objFolder.Items.Restrict(strFilter)
If filteredItems.Count = 0 Then
Debug.Print "No emails found"
Found = False
Else
Found = True
' this loop is optional, it displays the list of emails by subject.
For Each itm In filteredItems
Debug.Print itm.Subject
Next
End If ...
....
The above code searches my default e-mail (for instance, jsmith@example.com), however, I have a secondary e-mail called Retail Finance , (rfin@example.com) and I want to search that e-mail addresses inbox. How can I modify my code to accomplish this?
I'm new to Outlook VBA, sorry if this is basic.