Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 email attach files

Author  Topic 

rudba
Constraint Violating Yak Guru

415 Posts

Posted - 2012-02-17 : 11:36:38

how do we attach all documents file form specific path?

DECLARE @strBody varchar (max)
DECLARE @AttFiles varchar (255)
DECLARE @SendTo varchar(255)
DECLARE @FirstName varchar (255)

SET @AttFiles='E:\attach\*.doc'

SET @strBody='<html><body>This is...</html>'
set @SendTo='abc@abc.com;xyz@xyz.com'
EXEC msdb.dbo.sp_send_dbmail @recipients=@SendTo,
@subject = 'Test',
@body_format='HTML',
@body = @strBody,
@file_attachments =@AttFiles

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-02-17 : 14:14:59
you have to either list all the documents or use a looping logic to get list onto a variable and use it

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -