2

We have a function that uses SP_Send_DBMail. A user that has the DatabaseMailUserRole can send messages, but as soon as he attaches a file from a network share he receives the following error:

MSG 22051, Level 16, State 1, Line 0 Failed to open Attachment file '\....'. Access Denied.

He has read / write permissions on the network share. The SQLAgent account has read / write on the network share.

The application can send attachments fine, but he can't while walking the code or from the server.

If I grant him SysAdmin (only for testing) he can send the attachment.

What am I missing here?

  • Is he running it from a remote computer? From Books Online: "Windows does not allow SQL Server to provide credentials from a remote computer to another remote computer. Therefore, Database Mail may not be able to attach files from a network share in cases where the command is run from a computer other than the computer that SQL Server runs on." – Robert L Davis Dec 17 '14 at 00:42
  • He is remotely connected via SSMS yes, but I am as well, and I can do it as a SysAdmin. He can as well when granted SysAdmin role. – RYAN DESMOND DBAGooner Dec 17 '14 at 12:45
  • Try to map shared resource as local drive to server where SQL Server installed. – Serg Dec 29 '14 at 06:48

1 Answers1

-1

I experienced the same problem and found a solution.

I gave delegation to sql server service account which is active directory account, then the problem disappeared. The application must be restarted after delegation permission configuration.

enter image description here