you can use a procedure for this. just add a sql server agent job to call this procedure and inside procedure add a logic like belowCREATE PROCEDURE SentVotingMailASDECLARE @Voting_Receipients Table(ID int IDENTITY(1,1)... columns)INSERT @Voting_Receipients (Other columns except ID here...)SELECT columnsFROM tableWHERE voteUntil >= DATEADD(dd,DATEDIFF(dd,0,GETDATE()),0)AND voteUntil < DATEADD(dd,DATEDIFF(dd,0,GETDATE()),1)DECLARE @ID int,@Recipient_Email varchar(100)SELECT @ID=MIN(ID)FROM @Voting_ReceipientsWHILE @ID IS NOT NULLBEGINSELECT @Recipient_Email =Recipient_Email FROM TableWHERE ID = @IDEXEC sp_send_dbmail ...SELECT @ID=MIN(ID)FROM @Voting_ReceipientsWHERE ID > @IDENDGO
Im assuming you've recipient details stored in same table. If not, make sure you put correct column table names for getting the values.------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/