Results 1 to 5 of 5
  1. #1
    Join Date
    Apr 2004
    Posts
    31

    Talking Unanswered: SP or trigger for email of new record insert to table

    Does anyone have a stored procedure for sending an email (using SQLMail) when a new record is added to a database table?

    I have SQLMail all setup, I just need a good example of a stored procedure or trigger that will sending an email with the details for a new record entry into a table.

    thanks!

  2. #2
    Join Date
    Mar 2004
    Location
    West London
    Posts
    34

    Cool Trigger Mail

    Does depend on what you want to say but here a start.

    CREATE TRIGGER [NewRowsAdded] ON [dbo].[tablename]
    FOR INSERT
    AS


    exec master.dbo.xp_sendmail
    @recipients = 'joe.bloggs@bloggs.co.uk',
    @subject = 'New Rows Added',
    @message = 'Hey theres some new rows? Take a peek!'

  3. #3
    Join Date
    Apr 2004
    Posts
    31
    Thank you for the reply!

    I have our Help Desk database setup in SQL Server 2K. Basically, I would like to send an email to the user (field name: userid, which also works for their email) and a copy to our main distribution address - helpdesk@somewhere.com.

    Each record that is added should generate this email and send to the parties listed above.

    thanks again for your help!

  4. #4
    Join Date
    Mar 2004
    Location
    West London
    Posts
    34
    So do you want to inlcude details of the row or just email the addresses (in which case add as many email address as you like name@bla;name@bla

  5. #5
    Join Date
    Apr 2004
    Posts
    31
    I would like to add the field information as well. So I have the following as fields that I would like to include in the email:

    ticketID
    loggedby
    ActualHours
    LoggedDate
    RequestDate
    TicketDetails
    FinalOutcome

    Thanks!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •