In Just continuation of my Previous POST, I am writing this to share how to fire an email from SQL Query that you can further use in your Stored Procedures.
Query that you need to write is –
Above Query will send an Email to the the Recipients you added in the Query. Make sure you have configured your email Properly as explained in the previous Post otherwise you will end up with an error.
Now to see the Logs of the Emails sent you can open – View History Log.
This will open the the Window where you can trace each and every logs along with the Error messages
In the left Panel you will find each and every options for Auditing.
I just got a requirement where I was suppose to send an Email from SQL, So here in this Post I will share how to send an Email from SQL followed by another Post in which I will share How to execute it with a SQL Query.
So the first step you need to do is to open SQL Server Management Studio. Navigate to Management –> Database Emails as shown in the below screenshot.
Now either you can Right click on Database Email OR double click on Database Email to open the Configuration Wizard as shown above. Now simply push Next
As we are configuring it for the first time so we are good to go with the first option. Push Next.
Now here we need to Configure the SMTP Server with proper SMTP Credential. It’s almost the same configuration window which we use do define from NAV Side. After finishing this you need to push Next and afterwards you will get 2 more dialogue boxes where you have to do nothing and you just need to finish the configuration wizard.
Now you need to fire below SQL Query on Database msdb.
Now you are good to go and have completed all needed configurations to fire an email from SQL Side. See below screenshot to fire a test email.
Open Send Test E-Mail. Here you need to enter the recipient Email ID and push Send Test Email.
You will receive an Email.
P.S – You Should have desired Permission from SQL Side then only you can configure OR Use this Email Feature.