How to send email from SQL Server Jobs in SQL Server 2014. I want to implement email notification through stored procedure instead of Windows services.
You need to first configure DB mail in SQL Server in order to utilise this functionality. You can use below link as a referece for DB mail configuration purposes.
Once DB mail is setup you can enable database mail on SQL Server Agent. The same link describes how to do that. Once it is enabled on SQL Server Agent, you need to restart the SQL Server Agent Service to make that take effect.
That's it. Now you can use
msdb.dbo.sp_send_dbmail SP to send email using SQL Server Agent job or stored procedure.
First Setup a Database Mail account, Database Mail profile and use the below code in your SP.
EXEC msdb.dbo.sp_send_dbmail @profile_name='Mymail', @recipients='MYmail@company.com', @subject = 'Mail subject' , @body = 'Mail body' , @file_attachments = 'G:\BACKUP\data\log.txt' --Path to attachment if any
You can always refer to MSDN for more options
You can send the email(s) by using the SQL Server's extended stored procedure
Look here for the documentation.