'****************************************************************************
' Processing Starts Here
'****************************************************************************

Set ShellObj = WScript.CreateObject("Wscript.Shell")
Set NetObj = WScript.CreateObject("WScript.Network")
Set FSO = WScript.CreateObject("Scripting.FilesystemObject")
Set XMLHTTP = WScript.CreateObject("Microsoft.XMLHTTP")
CompName = UCASE(Trim(NetObj.ComputerName))

strDriveLetter = "C:" 
intCount = 0 
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")

On Error Resume Next 

respond = MsgBox("Do you wish to begin removing the birthday from ABAC contacts?", vbOKCancel)
If respond = 2 Then
	MsgBox "Exiting without updating contacts."
	WScript.Quit
End If

Const adOpenForwardOnly = 0
Const adOpenKeyset = 1
Const adOpenDynamic = 2
Const adOpenStatic = 3
Const adLockReadOnly = 1
Const adLockPessimistic = 2
Const adLockOptimistic = 3
Const adLockBatchOptimistic = 4

On Error Resume Next

MsgBox "Removing Birthday for Outlook Contacts for ABAC...."


Set myOlApp = CreateObject("Outlook.Application")
Set myNameSpace = myOlApp.GetNameSpace("MAPI")
Set objContactsFolder = myNameSpace.GetDefaultFolder(10)
Set objContacts = objContactsFolder.Items
NumItems = objContacts.Count
'MsgBox "You have a total of " & NumItems & " Outlook contacts to be searched to find your ABAC contacts."

On Error Resume Next

ModCount = 0
AddCount = 0
DelCount = 0
DelFlag = 0

StartDateTime = Now()

Categories = "ABAC"

SearchStr = "[Categories] = " & chr(34) &  Categories & chr(34)
Set MyContact = objContacts.Restrict(SearchStr)
' Process the changes
'For Each objContact In objContacts
For Each objContact In MyContact
	If (Instr(1,ucase(objContact.Categories),"ABAC") > 0) and (Instr(1,ucase(objContact.Categories),"ABAC Ex") = 0) and (Instr(1,ucase(objContact.Categories),"ABAC DL") = 0) Then
		If objContact.Birthday <> "1/1/4501" Then
			objContact.Birthday = "1/1/4501"
			objContact.Save
			ModCount = ModCount + 1
			rst.close

		End If
	End If
Next

MsgBox "You have a total of " & ModCount & " Outlook ABAC contacts whose birthday was removed."

'MsgBox "Finished removing birthdays for ABAC category"

' Clean up
rst.Close
conn.Close
Set objContact = Nothing
Set objContacts = Nothing
Set objContactsFolder = Nothing
Set myOlApp = Nothing
Set myNameSpace = Nothing
set rst = nothing
set conn = nothing
session.Abandon

WScript.Quit
