Note that there are some explanatory texts on larger screens.

plurals
  1. POScheduled job not sending emails
    text
    copied!<p>I believe that dbMail is properly set up, I can send an email to myself using it. But I have a scheduleded job which looks like;</p> <pre><code>DECLARE @Forename VARCHAR(50) DECLARE @EmailAddress VARCHAR(50) DECLARE @subject VARCHAR(500) DECLARE @emailsubject VARCHAR(500) Declare @bodypre as varchar(5000) DECLARE @body VARCHAR(5000) declare @recipients VARCHAR(5000) Declare @emailStop as int declare @replaceApproverName as varchar(20) declare @link as varchar(100) declare @replaceNextLine as varchar(20) declare @profile_name as varchar(50) declare @bodypost as varchar(5000) declare @footerMessage as varchar(1000) set @replaceApproverName ='$Approver' set @replaceNextLine ='$NextLine' set @link ='$Link' DECLARE @NewLineChar AS CHAR(1) = CHAR(13) select @emailsubject=EmailMessageSubject, @bodypre = EmailMessageBody, @emailStop = EmailStop_Flag from STAS.dbo.MC_STAS_EmailMessage where TimeSheetStatusID = 2 SET @bodypre =Replace(@bodypre ,@link, 'http://liveweb.website.com/stas'); select @footerMessage =EmailMessageBody from STAS.dbo.MC_STAS_EmailMessage where MessageType='Footer' SET @bodypre += @footerMessage; SET @bodypre =Replace(@bodypre ,@replaceNextLine, @NewLineChar) ; DECLARE emailCursor CURSOR FOR SELECT distinct EmailAddress,Forename from [STAS].[dbo].[NotifictationEmailID_View] vw OPEN emailCursor FETCH NEXT FROM emailCursor INTO @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 FROM emailCursor INTO @EmailAddress,@Forename END CLOSE emailCursor DEALLOCATE emailCursor </code></pre> <p>When I look at the Database mail error log I see this;</p> <pre><code>The mail could not be sent to the recipients because of the mail server failure. (Sending Mail using Account 1 (2013-09-04T14:03:48). Exception Message: Cannot send mails to mail server. (The operation has timed out.). Sending Mail using Account 1 . Exception Message: Cannot send mails to mail server. (Failure sending mail.). </code></pre> <p>Yet the profile 'STAS Alert' is set up and I can send an email using it to myself. So why is this happening and what should I do to fix it?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload