Sooraj Bathery
Sooraj Bathery

Reputation: 155

Send SQL Server Email With Attachment Without Using sysadmin privilege

I am trying to send an email using the sp_send_dbmail stored procedure of SQL Server with an attachement,

My account doesn't have sysadmin privileges, when an attachement is sent as normal SQL Server user, I get this error

The client connection security context could not be impersonated. Attaching files requires an integrated client login

Is there is any way to send SQL Server email with attachement without using sysadmin privileges?

Upvotes: 3

Views: 8530

Answers (3)

Prem
Prem

Reputation: 1

Please check the directory where the attachments are stored and ensure that the SQL Server service account has full access to that path.

Upvotes: -1

Krushnakumar Joshi
Krushnakumar Joshi

Reputation: 1

This will solve the problem , you just need to provide sysadmin rights to the sql user ,
Command : sp_addsrvrolemember 'User', 'sysadmin'

Upvotes: -1

marc_s
marc_s

Reputation: 754268

Well, if you would have looked at the MSDN documentation for sp_send_dbmail, it says:

Database Mail uses the Microsoft Windows security context of the current user to control access to files. Therefore, users who are authenticated with SQL Server Authentication cannot attach files using @file_attachments. 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.

So from this it's clear you have to be connected to SQL Server using Windows authentication (with Integrated Security=SSPI; in your connection string) in order to be able to attach files to e-mails.

Upvotes: 2

Related Questions