x

trigger to send Mail to an gmail or yahoo account

I want to create a trigger which executes the stored procedure

xp_sendmail or sp_send_dbmail. which one is correct.

By creating a trigger i need to send an email from the database and i am using sql server 2005.

'For this i used xp_sendmail but it is asking for parameter @user.

Kindly provide the detailed information how can i overcome these problems in sql server 2005 to send an email to a gmail or yahoo account using my trigger.

With Regards,

Damus

more ▼

asked Feb 23 '10 at 03:35 AM in Default

Damus gravatar image

Damus
65 8 8 9

(comments are locked)
10|1200 characters needed characters left

2 answers: sort voted first

As you're on SQL 2005 you should use sp_send_dbmail. If you read the article Brimstedt linked to, you'll see that xp_sendmail is deprecated. It's only there for backwards compatibility.

more ▼

answered Feb 23 '10 at 04:48 AM

David Wimbush gravatar image

David Wimbush
4.7k 28 29 31

+1 - sp_send_dbmail is also much more reliable, configurable and doesnt require a SMTP Client (such as Outlook) to be installed on the server.
Feb 23 '10 at 05:51 AM Fatherjack ♦♦
Could you specify me that how can i use this sp_send_dbmail in my trigger, while i am executing it is diplaying 'Mail queued', but mail wasn't delivered.why it is like this?
Feb 23 '10 at 06:02 AM Damus
'Mail Queued' means that the email was succesfully added to the queue for processing - use sysmail_help_queue_sp to see what is being queued. Look at http://msdn.microsoft.com/en-us/library/ms190630(SQL.90).aspx or the same subject in BOL to help understand why your message isn't being delivered
Feb 23 '10 at 06:08 AM Kev Riley ♦♦
(comments are locked)
10|1200 characters needed characters left

Here is a helpful link: http://lmgtfy.com/?q=xp_sendmail

From what i can see in documentation, there is no @user parameter. There is @set_user, but it is not mandatory.

The docs further says that xp-sendmail is great for use in triggers, so i guess you're on the right track: http://msdn.microsoft.com/en-us/library/ms189505.aspx

Perhaps posting the exact error message you get can help us help you.

more ▼

answered Feb 23 '10 at 04:02 AM

Brimstedt gravatar image

Brimstedt
226 3 3 4

Halike it... +1 for the google link... Would like to +10 but it wont allow me ;-)
Feb 23 '10 at 08:28 AM sp_lock
(comments are locked)
10|1200 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

New code box

There's a new way to format code on the site - the red speech bubble logo will automatically format T-SQL for you. The original code box is still there for XML, etc. More details here.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

SQL Server Central

Need long-form SQL discussion? SQLserverCentral.com is the place.

Topics:

x1933
x29

asked: Feb 23 '10 at 03:35 AM

Seen: 2502 times

Last Updated: Feb 23 '10 at 06:09 AM