SQL Mail with @query argument failing

  • Please Help!!  I have been successfull using xp_sendmail with basic @recipient and @message arguments, but when I try to add results of a query, it fails every time with:

    xp_sendmail: Unable to login to SQL Server.

    ODBC error 18456 (28000) Login failed for user 'DOMAINNAME\Username'

    I've given this 'DOMAINNAME\Username' full sysadmin/dbo rights.

    I am trying this from query analyzer if that makes any difference.

    I've searched and searched and can't find what I'm missing.

    Any help would be much appreciated.

    Thanks,

    Nicole

     

  • Are you running the xp_sendmail from a Job?

    Can you post the code you used?

  • I have tried lots of different combinations of code, but here is a simple example that I can't even get to work:

    I run this from Query Analyzer:

    EXEC xp_sendmail 'nkelly@...', @query = 'sp_configure'

    Results:

    Server: Msg 17969, Level 16, State 1, Line 0

    xp_sendmail: Unable to login to SQL Server.

    ODBC error 18456 (28000) Login failed for user 'DomainName\Username'

    This works however:

    EXEC xp_sendmail 'nkelly@...', @message = 'sp_configure'

    Results:

    Mail sent.

     

     

  • Have you resolved your issue?

    I have the same problem. Could you let me know if you have solution.

    Thanks!

     


    Jie Ma

  • I have never gotten sendmail to work with a query.  I am assuming there is a security issue that I'm missing, but it seems like I tried everything.

    I had given up on this and put it on the back burner...

    But if you figure it out or anyone has any suggestions, that would be great!!

    Thanks and sorry I wasn't any help!

    ~Nicole

  • I found the answer.

    If you set deny permission on build in Administrator, and then the account you use to login SQL services has local/domain admin right, you will get this message in SQL 2000, but not in SQL 7.0.

     


    Jie Ma

  • Jie Ma,

    Could you please explain your answer a little more clearly.  I don't quite understand what you are saying to do.

Viewing 7 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic. Login to reply