As soon as a new lead is added to the database and a representative is assigned to him or her, send an email to the representative with the contact data from the leadThis can be done from within the SQL server without any external coding required.
- With an insert trigger the action can be started.
- Insertion of new leads should be fast and stable, so I decided not to send the email immediately but to store the email data in a history table. The added benefit for my customer is that he can have a list of these messages to follow up with his representatives.
- The insert trigger on the leads table inserts a new record in the history table.
- A stored procedure is made to read new records in the history table and mail a message to the representative.
- The stored procedure uses sp_send_dbmail.