FIX: xp_sendmail Fails with the @attach_results Parameter on SQL Server 2000 Personal Edition

Article translations Article translations
Article ID: 296098 - View products that this article applies to.
This article was previously published under Q296098
This article has been archived. It is offered "as is" and will no longer be updated.
BUG #: 353394 (SHILOH_BUGS)
Expand all | Collapse all

On This Page


The xp_sendmail extended stored procedure may raise the following error if you try to send query results by e-mail using the @attach_results parameter from SQL Server 2000 Personal Edition:
Server: Msg 18024, Level 16, State 1, Line 0
xp_sendmail: failed with operating system error 87
This problem does not occur when SQL Server 2000 Personal Edition is installed on Microsoft Windows 2000 Professional.


To resolve this problem, obtain the latest service pack for SQL Server 2000. For additional information, click the following article number to view the article in the Microsoft Knowledge Base:
290211 INF: How to Obtain the Latest SQL Server 2000 Service Pack


Microsoft has confirmed that this is a problem in SQL Server 2000. This problem was first corrected in SQL Server 2000 Service Pack 1.


The @attach_results parameter is an optional parameter for xp_sendmail which specifies that the result set of a valid query should be sent in e-mail as an attached file instead of being appended to the message. The default value for @attach_results is FALSE, which means that the query result set is appended to the message. If the @attachments optional parameter for xp_sendmail is not NULL and @attach_results is TRUE, the first file name in @attachments is used as the file name for the query results. If @attachments is NULL, a file name is generated with a .txt extension.

Steps to Reproduce Behavior

Execute the following statements in Query Analyzer after replacing <valid_email_address> with a valid email address:
EXEC @r = master..xp_sendmail	@recipients = '<valid_email_address>',
				@message = 'Message text',
				@query = 'SELECT * FROM titles',
				@subject = 'SQL Mail test to attach query results',
				@attach_results = 'TRUE',
				@dbuse = 'pubs'
The correct results on executing the code should be as follows:
Mail sent.


Article ID: 296098 - Last Review: October 23, 2013 - Revision: 3.3
  • Microsoft SQL Server 2000 Personal Edition, when used with:
    • Microsoft Windows 98 Standard Edition
    • Microsoft Windows Millennium Edition
kbnosurvey kbarchive kbbug kbfix kbsqlserv2000sp1fix KB296098

Contact us for more help

Contact us for more help
Connect with Answer Desk for expert help.
Get more support from