Hi-
I have easy code that is suppose to loop through a folder and return email addresses but I'm getting runtime error 438 Object doesn't support this method or property. I do have Microsoft Scripting Runtime reference on with Outlook 10.0 library. The code is:
Sub GetALLEmailAddresses()
Dim objFolder As MAPIFolder
Dim strEmail As String
Dim strEmails As String
''' Requires reference to Microsoft Scripting Runtime
Dim dic As New Dictionary
Dim objItem As Object
Dim myObj As Object
''Set objFolder = Application.ActiveExplorer.Selection
Set objFolder = Application.GetNamespace("Mapi").PickFolder
'Set objFolder = myFolder.SubFolders
For Each objItem In objFolder.Items
If objItem.Class = olMail Then
strEmail = objItem.SenderEmailAddress
If Not dic.Exists(strEmail) Then
strEmails = strEmails + strEmail + ";"
dic.Add strEmail, ""
End If
End If
Next
Debug.Print strEmails
End Sub
I have easy code that is suppose to loop through a folder and return email addresses but I'm getting runtime error 438 Object doesn't support this method or property. I do have Microsoft Scripting Runtime reference on with Outlook 10.0 library. The code is:
Sub GetALLEmailAddresses()
Dim objFolder As MAPIFolder
Dim strEmail As String
Dim strEmails As String
''' Requires reference to Microsoft Scripting Runtime
Dim dic As New Dictionary
Dim objItem As Object
Dim myObj As Object
''Set objFolder = Application.ActiveExplorer.Selection
Set objFolder = Application.GetNamespace("Mapi").PickFolder
'Set objFolder = myFolder.SubFolders
For Each objItem In objFolder.Items
If objItem.Class = olMail Then
strEmail = objItem.SenderEmailAddress
If Not dic.Exists(strEmail) Then
strEmails = strEmails + strEmail + ";"
dic.Add strEmail, ""
End If
End If
Next
Debug.Print strEmails
End Sub