NEVAEHSIN
asked on
VBS script Outlook error
I may have jumped the gun on accepting this solution.
https://www.experts-exchange.com/questions/24324004/VBS-that-will-remove-contacts-from-ms-outlook-2003.html
When I first tested it, it was on a small scale. I attempted to run it on account that had 153 unnecessary contacts and it had to be ran several times to delete all of them. As in first run it would delete 20 or so, next run it would delete 15, etc. The quantity the script deleted each time was not the same, but none the less it would not delete all of them.
The code is attached and the link above will explain what I was initially looking for. I need to run this once.
https://www.experts-exchange.com/questions/24324004/VBS-that-will-remove-contacts-from-ms-outlook-2003.html
When I first tested it, it was on a small scale. I attempted to run it on account that had 153 unnecessary contacts and it had to be ran several times to delete all of them. As in first run it would delete 20 or so, next run it would delete 15, etc. The quantity the script deleted each time was not the same, but none the less it would not delete all of them.
The code is attached and the link above will explain what I was initially looking for. I need to run this once.
On Error Resume Next
Const olFolderContacts = 10
strEnding = "@email.com"
intLength = Len(strEnding)
Set objOutlook = CreateObject("Outlook.Application")
Set objNamespace = objOutlook.GetNamespace("MAPI")
Set colContacts = objNamespace.GetDefaultFolder(olFolderContacts).Items
For Each objContact In colContacts
If LCase(Right(objContact.Email1Address, intLength)) = LCase(strEnding) Or _
LCase(Right(objContact.Email2Address, intLength)) = LCase(strEnding) Or _
LCase(Right(objContact.Email3Address, intLength)) = LCase(strEnding) Then
WScript.Echo objContact.FullName
'objContact.Delete
End If
Next
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Yes sorry, I forgot it was VBS you want and you did it correctly.
Chris
Chris
ASKER
I'm getting an error (800A0401) in regards to Line: 4, Char: 14 in the above code. I was probably supposed to edit it before running it. So, I removed the "As Long" and it worked perfectly and removed all the unnecessary contacts in one sweep.
Hopefully that "As Long" wasn't important :p