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@example.com', @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.