sql server - Scheduled job not sending emails -


i believe dbmail set up, can send email myself using it. have scheduleded job looks like;

declare @forename varchar(50)  declare @emailaddress varchar(50) declare @subject varchar(500) declare @emailsubject varchar(500) declare @bodypre  varchar(5000) declare @body varchar(5000) declare @recipients varchar(5000) declare @emailstop  int declare @replaceapprovername varchar(20) declare @link varchar(100) declare @replacenextline varchar(20) declare @profile_name varchar(50) declare @bodypost varchar(5000) declare @footermessage varchar(1000) set @replaceapprovername ='$approver' set @replacenextline ='$nextline' set @link ='$link' declare @newlinechar char(1) = char(13)   select @emailsubject=emailmessagesubject, @bodypre = emailmessagebody, @emailstop = emailstop_flag stas.dbo.mc_stas_emailmessage timesheetstatusid = 2   set @bodypre =replace(@bodypre ,@link, 'http://liveweb.website.com/stas'); select @footermessage =emailmessagebody  stas.dbo.mc_stas_emailmessage messagetype='footer' set @bodypre += @footermessage; set @bodypre =replace(@bodypre ,@replacenextline, @newlinechar) ;  declare emailcursor cursor   select  distinct emailaddress,forename  [stas].[dbo].[notifictationemailid_view] vw open emailcursor fetch next  emailcursor @emailaddress,@forename while @@fetch_status = 0  begin        if(@emailstop = 1) set @emailaddress = 'xxx.xxxx@xxxxx.co.uk' set @bodypost  = replace(@bodypre,@replaceapprovername,@forename)  exec msdb.dbo.sp_send_dbmail  @profile_name='stas alert',                                              @recipients =@emailaddress,                        @subject=@emailsubject,                                                      @body =@bodypost;  fetch next emailcursor @emailaddress,@forename end  close emailcursor  deallocate emailcursor  

when @ database mail error log see this;

the mail not sent recipients because of mail server failure. (sending mail using account 1 (2013-09-04t14:03:48). exception message: cannot send mails mail server. (the operation has timed out.). sending mail using account 1 . exception message: cannot send mails mail server. (failure sending mail.). 

yet profile 'stas alert' set , can send email using myself. why happening , should fix it?

did check out sql server agent properties/alert system ? mail profile should enabled , mail profile should chosen correctly.


Comments

Popular posts from this blog

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

html - How to style widget with post count different than without post count -

url rewriting - How to redirect a http POST with urlrewritefilter -