Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Getting run-time error 438 in VBA script in Outlook

Status
Not open for further replies.

joshinh

Programmer
Joined
Dec 22, 2006
Messages
1
Location
US
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

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top