Showing posts with label attachment. Show all posts
Showing posts with label attachment. Show all posts

Monday, March 19, 2012

Getting Results in an EMail PDF?

We have the following proc that executes an e-mail and attaches the resulting query as a TXT attachment. Is there a way to make the attachment be a PDF?

@.MYRECIPIENTS varchar (500)

, @.MYSUBJECT varchar (50)

, @.MYBODY varchar (500)

, @.MYQUERY varchar (1000)

, @.MYIMPORTANCE varchar (10)

, @.MYPROFILE varchar (50)

as

declare @.NewSubject varchar(200)

set @.NewSubject = @.MYSUBJECT + ' ' + Cast(GetDate() as varchar(20))

Execute msdb.dbo.sp_send_dbmail

@.profile_name = @.MYPROFILE

,@.recipients = @.MYRECIPIENTS

,@.subject = @.NewSubject

,@.body = @.MYBODY

,@.query = @.MYQUERY

,@.importance = @.MYIMPORTANCE

,@.attach_query_result_as_file = 1

,@.body_format = 'HTML'

Jim,

That's not directly possible. As you recall, SQL Server isn't a printer client, and has no direct capabilities to interact with printers, and PDF is a printer format.

However, you may find some usefulness from a Google? search for a freely available stored procedure that is called "sql 2 pdf".

|||Thanks for the lead. I will follow up on it