Database Mail does not work from SQL Agent Job

  • This always works for me.

    -- this configures the database mail on the server

    exec sp_configure 'show advanced options', 1

    reconfigure

    exec sp_configure 'Database Mail XPs', 1

    reconfigure

    -- this sends mail

    DECLARE @p_body as nvarchar(max), @p_subject as nvarchar(max)

    DECLARE @p_recipients as nvarchar(max), @p_profile_name as nvarchar(max)

    SET @p_profile_name = N'General Administration Profile' -- mail profile name

    SET @p_recipients = N'recipient@testemail.com;multiple.recipients@dbmail.com'

    SET @p_subject = N'This is a test mail using sp_send_dbmail'

    SET @p_body = 'This is an HTML test email send using <b>sp_send_dbmail</b>.'

    EXEC msdb.dbo.sp_send_dbmail

    @profile_name = @p_profile_name,

    @recipients = @p_recipients,

    @body = @p_body,

    @body_format = 'HTML',

    @subject = @p_subject

    A couple of things to check:

    1) Is your mail profile set to Default ? If not set this to yes.

    2) What authentication method are you using in your profile settings ? -- set this to anonymous to begin with.

    I hope this helps.

  • Try restarting the SQL Agent service.

  • It is the solution to my sql agent not sending email issue.

    Thanks Bala!

Viewing 3 posts - 16 through 17 (of 17 total)

You must be logged in to reply to this topic. Login to reply