I have found the following code on Dicks-Clicks website and I plan to change it so I can extract all email addresses in my send box.
However just running the code as is fails.
Can anyone suggest anything?
It fails on the first line
However just running the code as is fails.
Can anyone suggest anything?
It fails on the first line
user-defined type not defined
Code:
Sub GetFromInbox()
Dim olApp As Outlook.Application <- Fails here
Dim olNs As NameSpace
Dim Fldr As MAPIFolder
Dim olMail As Variant
Dim i As Integer
Set olApp = New Outlook.Application
Set olNs = olApp.GetNamespace("MAPI")
Set Fldr = olNs.GetDefaultFolder(olFolderInbox)
i = 1
For Each olMail In Fldr.Items
If InStr(olMail.Body, "ozark") > 0 Or _
InStr(olMail.Subject, "ozark") > 0 Then
ActiveSheet.Cells(i, 1).Value = olMail.ReceivedTime
i = i + 1
End If
Next olMail
Set Fldr = Nothing
Set olNs = Nothing
Set olApp = Nothing
End Sub