Wednesday, September 24, 2008

Sending Mail Via SSRS


First Way
· Open your SQL Server Management Studio · Login with your user name and password · Expand the “Management “folder. There you can find a tab with a name “Database Mail” · Right click on the “Database Mail” tab and select “Configure Database Mail”. Now a Database Mail Configuration Dialog Box will open. Click Next. · Now select Set up Database Mail by performing the following tasks and click next. · Give one profile name and click Add Button and New Account Button · Then give the account name, email address, display name, reply mail address, server name and port number then click ok button then click next button again click next button again click next button. · Then click the finish button and close button. · Open a query window and type the following query to send a mail to some others with attachment file
Query
EXEC msdb.dbo.sp_send_dbmail @recipients=N'joseph.v@gmail.com',@body='Mail From Query', @subject ='jose',@profile_name ='josephmail',@file_attachments ='C:\test.txt';
· The log related to Database Mail can be viewed by executing the statement below SELECT * FROM msdb.dbo.sysmail_event_log
Second Way · Go->StartàAll ProgramsàSQL Serverà2005 Configuration ToolàReporting services Configuration · Select Email Setting · Give one mail id for TO address · Give SMTP Server Name · Now go to report manager and run your report and then click subscription and then set time and date for delivery of the report