April 13, 2010 at 4:16 am
Hi,
I have a table (Users) which contains
UserName
Passaword
When new username is inserted into this table I just wanted to send the mail to that person's E-mail.
I will do using Trigger. But I don't know exact coding to send mails.....
Can any one help on this?
April 13, 2010 at 5:06 am
Look for sp_send_dbmail in Books Online or Google.
How to post data/code on a forum to get the best help - Jeff Moden
http://www.sqlservercentral.com/articles/Best+Practices/61537/
April 13, 2010 at 5:15 am
You could always include a call to xp_smtp_sendmail see below...
DECLARE @ERC INT
DECLARE @EmailFromAddress VARCHAR(100)
DECLARE @EmailToAddress VARCHAR(100)
DECLARE @EmailSubject VARCHAR(150)
DECLARE @EmailPriority VARCHAR(10)
DECLARE @EmailMessage VARCHAR(8000)
DECLARE @EmailServerAddress VARCHAR(100)
-- set email variables
SET @EmailToAddress = 'recipient@domain.com'
SET @EmailFromAddress = 'sender@domain.com'
SET @EmailPriority = 'Normal'
SET @EmailSubject = 'Email subject'
SET @EmailMessage = 'Message body'
-- send the email
EXEC @ERC = [master].[dbo].[xp_smtp_sendmail]
@FROM = @EmailFromAddress,
@TO = @EmailToAddress,
@priority = @EmailPriority,
@subject = @EmailSubject,
@message = EmailMessage,
@type = N'text/plain',
@server = N'0.0.0.0' -- IP of mail server
April 13, 2010 at 5:20 am
I am getting this error.
Msg 2812, Level 16, State 62, Line 18
Could not find stored procedure 'master.dbo.xp_smtp_sendmail'.
April 13, 2010 at 5:33 am
hi,
Use msdb.dbo.sp_send_dbmail...
or
see the link given below...
September 29, 2010 at 1:45 pm
Foe SQL 2005 and 2008, use:
EXEC msdb..sp_send_dbmail
@profile_name='Default',
@recipients= 'xyz@yahoo.com',
@subject= 'Test 1',
@body = 'This is a test message.',
@file_attachments = null,
@importance = 'HIGH',
@sensitivity ='CONFIDENTIAL'
Mary Ming Wang
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply