Dim strConn,Conn,RecObj,strSQL,strSubject,strStatus,strBody,objMail,strDate
Dim intCount,blnBCC : intCount = 0
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_GAME_REF_LINK"
Set dicGames=CreateObject("Scripting.Dictionary")

Set RecObj = CreateObject("adodb.recordset")
With RecObj
.Open strSQL,Conn
Do While .EOF = False
intCount= intCount + 1
strSubject = "Please complete the On-Line Referee Evaluation for your game #" & .Fields("GameID") & " on "&.Fields("Date")&" at "&.Fields("GameTime")
strBody = "<a href=""https://www.sportsmanager.us/RefEvalByCoach.asp?EvalID="&.Fields("URLID")&""" target=""_blank"">Click here</a> complete the On-Line Referee Evaluation for your game #"&.Fields("GameID") & " on " & .Fields("Date") & " at " & .Fields("GameTime")
strBody = strBody & "<br/>" & .Fields("SeasonLeague") & " - " & .Fields("HomeTeam") & " vs " & .Fields("Awayeam") & " @ " & .Fields("AreaName") 


Set objMail=CreateObject("CDO.Message")
objMail.Subject=strSubject
objMail.From = "ref@sportsmanager.us"
objMail.To = .Fields("Email")
'objMail.CC = "bhartiya.ravi@gmail.com"
If blnBCC = "T" Then
	objMail.BCC = "copy<copy@sportsmanager.us>"
End If 
objMail.HTMLBody = strBody
objMail.Send
Set objMail=Nothing
.MoveNext
Loop
.Close()
End With

Set RecObj = Nothing : Conn.Close() : Set Conn = Nothing

Set fs=CreateObject("Scripting.FileSystemObject")
Set f=fs.OpenTextFile("C:\ScheduleTask\RefCoachLink.txt", Appending) 
f.Write VBCRLF&intCount&" Emails Sent Sucessfully At "&Now()&VBCRLF&"------------------"
f.close()
Set fs=Nothing







