SqlAnswersMail is the Answer to Sending E-mail in Text, HTML or PDF using SQL Server

When choosing to produce a PDF document, you can configure a number of different properties, such as page width, length, orientation, page header, page footer, etc. There is a XML file, called defaultPDF.xml (see below), which is used to change the necessary parameters to fit the needs of your PDF documents.

For example, the following query will generate an e-mail with a PDF attachment.

exec sp_SendSAM
@subject=’PDF for Order Listl’,
@message=’Please find the order list which is attached here with’,
@query=’select * from Northwind..Orders’

Following is the attachment of PDF which was received from the SqlAnswersMail.

For those people who are using xp_sendmail, it’s very easy to migrate from xp_sendmail to SqlAnswersMail. In most cases, a simple find/replace action is usually all you need to start using SqlAnswersMail in place of xp_sendmail.

Another function that is available with the tool is generating PDF documents for other uses. You just need to copy and paste the result into a test file and save it into a PDF file extension, then you will get a PDF file. The following script will generate PDF files.

exec sp_SendSAM
@query=’select top 100 CustomerID, OrderDate,
ShippedDate, Freight, Shipname, ShipRegion
from Northwind..Orders
/*<title>Northeast Orders</title>*/’,

You can call the sp_SendSAM stored procedure from ADO and ADO.net, if desired.


The solution consists of a stored procedure, a COM file, and an EXE file that runs out-of-process and does not interfere with the core workings of the SQL Server, and thus will not decrease the current performance of the SQL Server.


E-mail is the prime method of support. A “Getting Started Guide,” along with the included SqlAnswersMail help file, is all you need to get started.


Leave a comment

Your email address will not be published.