I would like to explore my Outlook messages and if a message comes from email address xx@xxx, save the message in a local folder.
I tried this:
Sub FindIt()
Dim myOlApp As New Outlook.Application
Dim myNameSpace As Outlook.Namespace
Dim myInbox As Outlook.MAPIFolder
Dim myitems As Outlook.Items
Dim myitem As Object
Set myNameSpace = myOlApp.GetNamespace("MAPI")
Set myInbox = myNameSpace.GetDefaultFolder(olFolderInbox)
Set myitems = myInbox.Items
For Each myitem In myitems
If myitem.SenderEmailAddress = "xx@xx" Then
MsgBox (myitem.Subject)
End If
Next myitem
End Sub
I either get an error or I get nothing.
If this code works I will adjust it by replacing the MsgBox with SaveAs (XXXXX).