SQL Stored Procedure to Send Email based on a field condition
Hello. I want to setup a trigger that sends an email based on a field condition in my sql database. The field in the databased is called UserDef5 and if the filed does not equal United States then send an email where the body of the email shows visitors firstname and last name (fieldname in table is FirstName, LastName) with the subject of the email to say: Potential Foreign National.
I already created a profile via the database mail configuration wizard called MonitorEmailProfile and did a successful email test.
What I don't know is how to setup the simple syntax of the stored procedure along with the logic of not sending a duplicate email multiple times if the record has already been read.
I would then setup an job to run every xx minutes to run. Hope that makes sense.