ThrottleWorks
Excel Ninja
Hi,
I am trying to search a string in e-mail body.
For example, I am trying to search if 'Yamaha' is present in e-mail body.
I tried 'If olItem.Body = "yamaha" Then' line but it is not working.
I need to find the string as instring. Can anyone please help me in this.
I am trying to search a string in e-mail body.
For example, I am trying to search if 'Yamaha' is present in e-mail body.
I tried 'If olItem.Body = "yamaha" Then' line but it is not working.
I need to find the string as instring. Can anyone please help me in this.
Code:
Sub Email()
Dim olApplication As Outlook.Application
Dim olNameSpace As Outlook.Namespace
Dim olFolder As Outlook.MAPIFolder
Dim olItem As Object
Dim strDomain As String
Dim olProperty As Outlook.UserProperty
Set olApplication = New Outlook.Application
Set olNameSpace = olApplication.GetNamespace("Mapi")
Set olFolder = olNameSpace.GetDefaultFolder(olFolderInbox)
For Each olItem In olFolder.Items
If olItem.Body = "sub" Then
Range("A1").Value = "sub"
End If
Next olItem
Set olApplication = Nothing
Set olNameSpace = Nothing
Set olFolder = Nothing
Set olProperty = Nothing
End Sub