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

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)
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 theMicrosoft 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:
DECLARE @r AS intEXEC @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.
Attachment, Mail

Article ID: 296098 - Last Review: 10/23/2013 18:26:00 - Revision: 3.3

Microsoft SQL Server 2000 Personal Edition

  • kbnosurvey kbarchive kbbug kbfix kbsqlserv2000sp1fix KB296098