Sending email when a record is added
We have an online form that collects user info and writes it to our SQL server.
I want to send an email notification every time a new record is added so
that some follow up can be done.
I recognize that I need to write an insert trigger, but I don't know how
to get the contents of the row that was just added and send that in the body
of the email.
I created a simple test trigger and used my browser to fill out the form
and submit it
Here is the trigger I used:
CREATE TRIGGER [New Lead] ON [table1]
EXEC master..xp_sendmail 'TestAccount', 'Insert Trigger Test'
When I submit the form, I get this error:
Microsoft OLE DB Provider for ODBC Drivers error '80040e09'
[Microsoft][ODBC SQL Server Driver][SQL Server]EXECUTE permission denied
on object 'xp_sendmail', database 'master', owner 'dbo'.
/inforequest2.asp, line 157
1. Why am I getting that error
2. How do I write the trigger to send the contents of the record via email
-- Android Development Center
-- Cloud Development Project Center
-- HTML5 Development Center
-- Windows Mobile Development Center