Help!
Download Internet Security Pro Trial

With no effort on your part, Trend Micro Internet Security Pro automatically and continuously guards your computer, personal identity and online transactions from cybercriminals. Whether you are at home or away, you can protect your personal information from future and present threats with sophisticated identity protection features.

Object doesn't support this property


Post new topic   General Reply to Topic (not reply to a specific post)    Forums Home -> Programming VBA RSS
Next:  Headshot Requirements  
Author Message
sluice



Joined: May 27, 2008
Posts: 1



PostPosted: Tue May 27, 2008 12:08 pm    Post subject: Object doesn't support this property

I have sent emails to a number of employment agencies and some of the addresses are old and invalid. I get a non-deliverable message back which quotes the invalid email address in the body of the message. I want to extract this email address, search through my list of agencies, find the contact with that email address and delete the contact:

Sub addrcheck()
Dim myolApp As Outlook.Application
Dim toDelete As Object
Dim olAgencies As AddressList
Dim olAgency As ContactItem
Dim objNS As NameSpace
Dim regEx, Match, Matches
Dim olMessage As MailItem
Dim olInbox as MAPIFolder

Set myolApp = CreateObject("Outlook.Application")
Set objNS = myolApp.GetNamespace("mapi")
Set myFolders = objNS.Folders
Set olContacts = objNS.AddressLists
Set olInbox = objNS.GetDefaultFolder(olFolderInbox)
Set regEx = New RegExp ' Create a regular expression.
For Each Item In olContacts
If Item.Name = "Agencies" Then
Set olAgencies = Item
Exit For
End If
Next
'The Collect folder within Inbox is where the returned emails are stored
For Each Item In olInbox.Folders
If Item.Name = "Collect" Then
Set toDelete = Item
Exit For
End If
Next
toDelete.Display
'This displays the "Collect" folder correctly
'Set the email regex pattern
regEx.Pattern = "^[A-Za-z0-9_\.-]+@[A-Za-z0-9_\.-]+[A-Za-z0-9_][A-Za-z0-9_]$"
regEx.IgnoreCase = True ' Set case insensitivity.
regEx.Global = True ' Set global applicability.
For Each olMessage In toDelete
'Extract the email address
Set Match = regEx.Execute(Item.Body) ' Execute search.
For Each olAgency In olAgencies
'** This is where I get the error "Object doesn't support this property
'or method"**
If olAgency.Email1Address = Match Then
olAgency.Display
' olAgency.Delete
End If
Next
Next
End Sub

I am unable to discover why I'm getting the error message at this point in the program. Can anyone see why?
Back to top
Display posts from previous:   
Post new topic   General Reply to Topic (not reply to a specific post)    Forums Home -> Programming VBA All times are: Eastern Time (US & Canada) (change)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum