Sql Mail Gönderme

DECLARE @email nvarchar(250)

DECLARE @GECIKMISBAKIYE  VARCHAR(20)

DECLARE @GUN   VARCHAR(5)

DECLARE @CARI_ISIM nvarchar(100)

DECLARE @MESAJ AS VARCHAR(MAX)

DECLARE emailCursor CURSOR FOR

SELECT CARI_ISIM, CAST(GECIKMISBAKIYE AS money )   AS GECIKMISBAKIYE,CAST((-1*GUN) AS VARCHAR) AS GUN,CCMAIL FROM MR_NETJOB_VADE_UYARI WHERE EMAIL IS NOT NULL AND GECIKMISBAKIYE>=1000;

 

OPEN emailCursor;

FETCH NEXT FROM emailCursor INTO @CARI_ISIM,@GECIKMISBAKIYE,@GUN,@EMAIL

WHILE (@@FETCH_STATUS = 0)

BEGIN

SET @MESAJ='SAYIN ' +  @CARI_ISIM  +  ' ' +  @GECIKMISBAKIYE   + ' TL Borcunuzun Vadesi ' + @gun +  ' Gecikmiştir.'

 

EXEC msdb.dbo.sp_send_dbmail

@profile_name='Emar',

@recipients=@email,

@body=@MESAJ,

@body_format='HTML',

@subject='Vadesi Geçmiş Borcunuz';

FETCH NEXT FROM emailCursor INTO @CARI_ISIM,@GECIKMISBAKIYE,@GUN,@EMAIL

END

CLOSE emailCursor

DEALLOCATE emailCursor

GO

Bu makaleyi yararlı buldunuz mu?