Dim strConn,Conn,RecObj,strSQL,strSubject,strStatus,strBody,objMail,strDate
Dim intCount,blnBCC,strTeamA,strTeamB,dicGames,strGameID : intCount = 0
Dim strRefInfo,strGameInfo
Const Appending=8
strConn = "Provider=SQLOLEDB;Data Source=WIN-59JDF64IOMC;Initial Catalog=cloudspo_sportsmgr;User Id=cloudspo_sports;password=letmein@cliff64"

Set Conn = CreateObject("adodb.Connection")
With Conn
.ConnectionString  = strConn 
.Open 
End With

blnBCC = "T"

strSQL = "EXECUTE dbo.USP_PENDING_REF_REMAINDER_COUNT"

Set RecObj = CreateObject("adodb.recordset")
With RecObj
.Open strSQL,Conn
Do While .EOF = False
intCount= intCount + 1
strSubject = "Ref Pending Reminder: "&.Fields("Subject")
strBody = "You have pending referee assignments.  <a href=""https://www.sportsmanager.us/RefURLLogin.asp?TopLink=T&AssignedID="&.Fields("AssignURLID")
strBody = strBody & """>Click here</a> to accept or decline"
Set objMail=CreateObject("CDO.Message")
objMail.Subject=strSubject
objMail.From = "notices@sportsmanager.us"
If .Fields("Email") <> "" And IsNull(.Fields("Email")) = False Then
	objMail.To = .Fields("Email")
	'objMail.To = "bhartiya.ravi@hotmail.com"
Else
	objMail.To = "copy@sportsmanager.us"
End If
If .Fields("Email2") <> "" And IsNull(.Fields("Email2")) = False Then
	objMail.Cc = .Fields("Email2")
	'objMail.To = "bhartiya.ravi@hotmail.com"
Else
	objMail.Cc = "copy@sportsmanager.us"
End If

If blnBCC = "T" Then
	objMail.BCC = "copy<copy@sportsmanager.us>"
End If 
objMail.HTMLBody = strBody
objMail.Send
Set objMail=Nothing


.MoveNext
Loop
End With
RecObj.Close() : Set RecObj = Nothing : Conn.Close() : Set Conn = Nothing

Set fs=CreateObject("Scripting.FileSystemObject")
Set f=fs.OpenTextFile("C:\ScheduleTask\RefPending.txt", Appending) 
f.Write VBCRLF&intCount&" Emails Sent Sucessfully At "&Now()&VBCRLF&"------------------"
f.close()
Set fs=Nothing







