I am looking to read my Outlook inbox for all emails received today that have "Cancel Alert" in the subject.
In the body of the these emails there are two rows of data with 6 columns. Fairly simple email body as seen below
Record ID Date Name Date 2 Status Note
R-99864 06-20-2019 Fonsi 06-19-2019 Canceled Record was out of date range
I would like to extract the Record ID and place it into my excel worksheet.
I can identify my emails by searching for the email subject. However, I don't know how to extract the Record ID.
Can you please show me how to use Excel VBA to extract my Record ID?
Below is my code for determining my emails by the email subject.
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
Dim Found As Boolean
Set myNameSpace = myOlApp.GetNamespace("MAPI")
Set myInbox = myNameSpace.GetDefaultFolder(olFolderInbox)
Set myitems = myInbox.Items
Found = False
For Each myitem In myitems
If myitem.Class = olMail Then
If InStr(1, myitem.Subject, "Cancel Alert") > 0 Then
Debug.Print "Found"
MsgBox (myitem.Subject)
Found = True
End If
End If
Next myitem
'If the subject isn't found:
If Not Found Then
NoResults.Show
End If
'myOlApp.Quit
Set myOlApp = Nothing
End Sub