1

Topic: The file, which on other PC is not attached to the letter

I can not send the letter with nesting of a file which lies in a network:
Nesting does not cling

The message 22051, level 16, state 1, line 0
Attachment file \\10.0.2.114\c $\Letter\ATTACH\Temp\1.txt is invalid.

EXEC msdb.dbo.sp_send_dbmail
@profile_name = ' email ',
@recipients = ' 1@tank.ru ',
@body = ' Test ';
@subject = ' Test ';
@file_attachments = ' \\10.0.2.114\c $\Letter\ATTACH\Temp\1.txt ';
The file is. c machines where the service sql server works I can address to the specified address.
But request,

DECLARE @result int
EXEC @result = master. xp_cmdshell ' DIR \\10.0.2.114\*.txt'

Returns that the Logging in is not produced: the user name or the password are not identified.

2

Re: The file, which on other PC is not attached to the letter

NewIvanovec;
sql server works under  the domain administrator

3

Re: The file, which on other PC is not attached to the letter

One is direct in one.
http://www.sqlservercentral.com/Forums/ … 526-2.aspx
TLTR: Access to a folder on the server should be at this mystical "the domain administrator".

4

Re: The file, which on other PC is not attached to the letter

M very important nuance to fulfill such  it is possible only from under the security account of the server with  sysadmin.
Otherwise does not fly up.

5

Re: The file, which on other PC is not attached to the letter

NewIvanovec wrote:

but request,

DECLARE @result int
EXEC @result = master. xp_cmdshell ' DIR \\10.0.2.114\*.txt'

Returns that the Logging in is not produced: the user name or the password are not identified.

And you are connected to a sequel as the system administrator or not?

BOL wrote:

When it is caused by the user who is not a member of the predetermined server role sysadmin, procedure xp_cmdshell is connected to Windows by means of a name of the security account and the password which are stored in the registration data with a name ##xp_cmdshell_proxy_account##. If this intermediary registration data does not exist, procedure xp_cmdshell completes performance with an error.

6

Re: The file, which on other PC is not attached to the letter

I make changes. sql server works under  LocalSystem.
Agent - under  Network Service.
The intermediary sp_xp_cmdshell_proxy_account added record.
In window Managment studio from a role nt authority \system and  SA

exec master. xp_cmdshell ' dir "\\10.0.2.114 \with $"'

request
Returns the Logging in it is not produced: the user name or the password are not identified.
In the agent whom the same error works under  Network Service

7

Re: The file, which on other PC is not attached to the letter

NewIvanovec wrote:

sql server works under  LocalSystem.

Purely I theorize...
Can consider to you such variant:
Safety-> the Registration data-> ##xp_cmdshell_proxy_account## - the domain user <DOMAIN> \<USER>.
For a network folder access on reading for <DOMAIN> \<USER>.
We modify the code of sending of letters so that all files for  were copied before sending in a local folder with a temporal name, and accordingly, in  links to local copies were transferred.
Access on a local folder for LocalSystem on reading, the full access on a local folder for <DOMAIN> \<USER>.
After sending - to delete from a local folder temporal files.

8

Re: The file, which on other PC is not attached to the letter

Damirovich wrote:

is passed...
Purely I theorize...
Can consider to you such variant:
Safety-> the Registration data-> ##xp_cmdshell_proxy_account## - the domain user <DOMAIN> \<USER>.
For a network folder access on reading for <DOMAIN> \<USER>.
We modify the code of sending of letters so that all files for  were copied before sending in a local folder with a temporal name, and accordingly, in  links to local copies were transferred.
Access on a local folder for LocalSystem on reading, the full access on a local folder for <DOMAIN> \<USER>.
After sending - to delete from a local folder temporal files.

Launched the server from  with the rights of the domain administrator and the problem dared.
But that the agent has been launched from same  is not clear and through the agent the letter did not go.
Can, through any time I will understand why so happened.
Ruslan Damirovich and alexeyvg many thanks

9

Re: The file, which on other PC is not attached to the letter

NewIvanovec wrote:

launched the server from  with the rights of the domain administrator and the problem dared.
But that the agent has been launched from same  is not clear and through the agent the letter did not go.

you wrote that "Agent - under  Network Service."
Well and further, xp_cmdshell it is fulfilled or under  a sequel, or under  xp_cmdshell_proxy_account
And under  the agent it will not be fulfilled (in sense, it I all about authorization "outside", for OS).