title: Configuring Sql Server job alerts to send email to users in a particular time
body: <p>I have created a job alert for sending emails to user everyday. I have used Database mail and wrote a script to a send an email to users who falls in the particular category. 
  But I want to send this email to the users only for three days. Email should be sent to the all users for three days only. </p>
  
  <p>Updated:</p>
  
  <pre><code>DECLARE @name VARCHAR(20),
  @birthdate datetime,
  @email NVARCHAR(50),
  @id nvarchar(MAX)
  DECLARE @body NVARCHAR(1000)
  DECLARE CC1 CURSOR READ_ONLY
  FOR
  SELECT Name, Birthdate, Email
  FROM TestDB.dbo.cust
  OPEN CC1
  FETCH NEXT FROM CC1 INTO 
  @name, @birthdate, @email
  WHILE @@FETCH_STATUS = 0
  BEGIN
      SELECT @id= Ename  FROM TestDB.dbo.TestEmail
      IF @email = @id 
      BEGIN
      EXEC msdb.dbo.sp_send_dbmail
      @profile_name = 'vate',
      @recipients = 'vegeta@gmail.com',
      @body = 'The stored procedure finished successfully.',
      @subject = 'Automated Success Message' ;
      END
      FETCH NEXT FROM CC1 INTO 
      @name, @birthdate, @email
  END
  CLOSE CC1
  DEALLOCATE CC1
  </code></pre>