hi
I Want to send mail daily Report through sql.what are the basic step for that
Its Very Urgent
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Manas MohapatraRank #182 · 13.2K reputationPosted Nov 7, 2016, 9:38 PM EST
Ananth GRank #1,176 · 1.5K reputationPosted Nov 7, 2016, 11:26 PM EST
Step 1
Log in to SQL Server 2008 with a correct user name and password.
Step 2
Expand the Management tab, then select SQL Server Logs, then right-click on Database Mail, then select Configure Database Mail.
Step 3
The following window appears:
Click Next.
Step 4
Select the Set up Database Mail by performing the following tasks: radio button.
Step 5
Click Next, then a confirmation box appears; click OK on that.
Step 6
When you click OK, then write the profile name description and click on Add.
Step 7
Then, 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 8
Then in the new window, it will show your profile, check that and click Next.
Step 9
Then in the new window, the Configure System Parameters description is shown.
Step 10
Click Next. It will show a confirmation about your profile; click Finish.
Step 11
Now the email service has been configured, click Close.
Step 12
Send a test email by right-clicking on database mail and click Send Test E-Mail.
Step 13
Provide the Test Email Id and click On Send Test E-Mail. Then check your mail to see if you got the mail. Enjoy!!
Note
After 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 the
sp_configureStored Procedure, as shown here:Output Message
The Configuration option "show advanced options" changed from 0 to 1. Run the
RECONFIGUREstatement to install.The configuration option "Database Mail XPs" changed from 1 to 1. Run the
RECONFIGUREstatement 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.
GO EXEC sp_send_dbmail @profile_name='MyTestMail', @recipients='[email protected]', @subject='My Test Mail Service.', @body='Database Mail Received Successfully.'This is the body of this message.
Note
If you are using a database other than msdb, then use a stored procedure like
msdb.dbo.sp_send_dbmail. The log can be checked insysmail_logtable as shown below:SELECT * FROM sysmail_mailitems GO SELECT * FROM sysmail_log GO select * from sysmail_logPradeep SahooRank #489 · 5.1K reputationPosted Nov 8, 2016, 3:48 AM EST
snowal raj160 reputationPosted Nov 8, 2016, 9:07 PM EST