I am trying to setup the SQL server to send automatically an email every time a new record is inserted in one table. I have setup the Database Mail and it is working perfectly when I run the app locally from Visual Studio. But at soon as I publish it to the company IIS server, it fails and worse any new record are not even inserted in the table.
What could make it work on the local IIS express and not on the company IIS server? I went to IIS Manager and I haven't found any settings regarding SMTP with a SQL server..
Here is the code for the trigger which again works but only locally. Thanks.
CREATE TRIGGER dbo.trigger1
ON dbo.******
AFTER INSERT
AS
BEGIN
DECLARE @bodyHtml AS VARCHAR(100)
SET @bodyHtml = 'http:***************'+ CAST (( SELECT MAX(Number) FROM *****) AS nvarchar(max))
EXEC msdb.dbo.sp_send_dbmail
@profile_name = '**********',
@recipients = '**********',
@subject = '***********',
@body = @bodyHtml,
@body_format = 'HTML';
END
GO