September 7, 2005 at 2:34 am
I have a need to mail a small output file following the completion of an SQL Agent job.
Is this possible, and if so, what do I do?
Gary
Now sorted;please ignore
September 7, 2005 at 5:34 am
It is possible. You will need to add a final step to the job to fire off xp_sendmail. See BOL for information about it and how to set it up for attachments.
Good Hunting!
AJ Ahrens
webmaster@kritter.net
September 8, 2005 at 11:12 am
Here's something I use... hopefully I haven't hacked it apart too much... Just substitute the correct server and DB names where indicated..
- hth - Mark
DECLARE
@mailto1 AS VARCHAR(200),
@qvar1 VARCHAR(4000)
SET @qvar1 = 'SELECT fld1, fld2 FROM DataSqlSvrName.DatabaseName.dbo.vw_ViewName WHERE DataDate >= ''8/1/2005'''
SET @mailto1 ='addr1@xyz.com;addr2@xyz.com'
EXEC ServerNameThatHasSqlMailRunning.Master.dbo.xp_sendmail @recipients = @mailto1,
@subject = 'Subject Line here...',
@width=256,
@copy_recipients='',
@query = @qvar1,
@attach_results='TRUE',
@message='Message body here... See attachment to view records.',
@separator=' '
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply