I'm trying to send an email through SQL Server. The sp_send_dbmail has a parameter to specify the path of a file to send as an attachment. It works perfectly when the file is in the same server where SQL Server is hosted. However, I need to send a file that is stored on another server or computer in the same network.

How can I specify the path for such file?

Edit: I see no errors in the server agent logs nor dbmail. I ran this query: Select * FROM sys.dm_server_services and gave the account under the service_account column full control of the file in the remote server.

This is how I'm calling the sp:

EXEC msdb.dbo.sp_send_dbmail
    @profile_name = 'Profile',
    @recipients = '[email protected]',
    @subject = 'Testing Attachments',
    @file_attachments = '\\servername\c$\Temp\OutputReport.pdf'

Error: Msg 22051, Level 16, State 1, Line 0

Attachment file '\\servername\c$\Temp\OutputReport.pdf' is invalid.


1 Answer 1


Using an administraive share, such as C$ means the SQL Server Service Account needs to be a member of the remote machine's local Administrators group.

Instead of using the drive's administative share, create a new share at the folder where the file exists and ensure the SQL Server Service Account has access to both the Share and the file system folder where the file exists.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.