question

Chitra avatar image
Chitra asked

Send Database email

I have configured the Database Mail, and the test email is successful. I have to also use this database Mail profile and build the SQL Server Agent job called Automated Email. When the job run, I want the email to be sent to the administrators that backup job was successsful and it should include all the files created in the backup process. So in the job command the code is as the following: The job runs successfully but when I add the following parameter @file_attachment = 'C:\Program Files\Microsoft SQL Server.....error the Access denied. What is the right way to work on that, how do I cross this hurdle. I am using sqlserver 2005.

Use msdb GO EXEC sp_send_dbmail @profile_name ='DB Mail Profile', @recipients ='csaha@imsa.edu', @copy_recipients ='csaha@imsa.edu', @blind_copy_recipients='csaha@imsa.edu', @body ='This is a test message', @subject='Database Backup', @body_format='TEXT', @importance='Normal', @sensitivity='Normal'

Chitra

maintenance-plans
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
Nathan Skerl avatar image
Nathan Skerl answered

Im not sure this is such a great idea, but the account that SQL is running under will need read access to the directory. Look at the sql services if you dont know which account it is. I dont know if you have another drive available, but it would be preferred that you write the backup somewhere other than the sys drive.

Although this may get you by the 'access denied' error, you will probably run into problems given that @file_attachment has a 1mb limit by default. This can be changed in dbmail config.

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.