您好,欢迎访问一九零五行业门户网

How to send email using sqlserver

this is from codeproject:http://www.codeproject.com/articles/846204/how-to-send-mail-using-sql-server-part introduction there are three parts for this tutorial: configure email profile and send test email using sql server select and send d
this is from codeproject:http://www.codeproject.com/articles/846204/how-to-send-mail-using-sql-server-part
introductionthere are three parts for this tutorial:
configure email profile and send test email using sql serverselect and send data in mailschedule daily mail from sql serverstep 1log in to sql server 2008 with a correct user name and password.
step 2expand the management tab, then select sql server logs, then right-click on database mail, then select configure database mail.
step 3the following window appears:
click next.
step 4select the set up database mail by performing the following tasks: radio button.
step 5click next, then a confirmation box appears; click ok on that.
step 6when you click ok, then write the profile name description and click on add.
step 7then, a new window appears where you provide your profile name and configure outgoing mail server(smtp) then click basic authentication and provide your email id and password then click ok.
step 8then in the new window, it will show your profile, check that and click next.
step 9then in the new window, the configure system parameters description is shown.
step 10click next. it will show a confirmation about your profile; click finish.
step 11now the email service has been configured, click close.
step 12send a test email by right-clicking on database mail and click send test e-mail.
step 13provide the test email id and click on send test e-mail. then check your mail to see if you got the mail. enjoy!!
noteafter the account and the profile are created successfully, we need to configure the database mail. to configure it, we need to enable the database mail xps parameter using thesp_configure stored procedure, as shown here:
collapse |copy code
sp_configure 'show advanced', 1 go reconfigure go sp_configure 'database mail xps', 1 go reconfigure go
output messagethe configuration option show advanced options changed from 0 to 1. run the reconfigure statement to install.
the configuration option database mail xps changed from 1 to 1. run the reconfigure statement to install.
use the following query to send mail using query:
send mail query
use msdb;--must use msdb database, otherwise you will get error.
collapse |copy code
go exec sp_send_dbmail @profile_name='mytestmail', @recipients='manishki@live.com', @subject='my test mail service.', @body='database mail received successfully.'
this is the body of this message.
noteif you are using a database other than msdb, then use a stored procedure like msdb.dbo.sp_send_dbmail. the log can be checked in sysmail_log table as shown below:
collapse |copy code
select * from sysmail_mailitems go select * from sysmail_log go select * from sysmail_log
其它类似信息

推荐信息