Tuesday, June 22, 2010

Send Email Using SQL-Server 2005

Send Email Using SQL-Server 2005
 
Execute following stored proc:
 
Step 1
use master
go
sp_configure 'show advanced options',1
go
reconfigure with override
go
sp_configure 'Database Mail XPs',1
go
reconfigure
go

Step 2

EXECUTE msdb.dbo.sysmail_add_account_sp
    @account_name = 'RajeevailAccount',
    @description = 'Mail account for Database Mail',
    @email_address = 'makclaire@optonline.net',
    @display_name = 'MyAccount',
 @username='xxxx@xxxxx.net',
 @password='xxxxx',
    @mailserver_name = 'mail.xxxxxx.net'

Step 3
Send Email:-
EXEC msdb.dbo.sp_send_dbmail
@recipients=N'xxxxxxx@gmail.com',@body='Test Message Body',
@sensitivity ='Personal',
@importance ='High' ,
@copy_recipients ='yyyyyykum@gmail.com',@subject ='Test Message Subject',
@profile_name ='RajeevailAccount';

1 comment:

sriganesh said...

hi raj when i execute your query i had the following error

Msg 14607, Level 16, State 1, Procedure sysmail_verify_profile_sp, Line 42
profile name is not valid