May 11, 2006 at 8:51 pm
This stored procedure will send an attachment
EXEC master.dbo.xp_sendmail 'email@domain,net',
@message='email text is entered here',
@subject='TestSendingAttachments',
@attachments='c:\testlamp.txt'
I need @attachments to be the result of a query. Something like:
@attachments = SELECT FilesToAttach FROM TableAttach
I'm having a hard time with the syntex. Thanks for any help!!
May 12, 2006 at 3:54 am
This is getting closer, but only picks up the last record from the table. If there were 5 rows (file names) it only sends the last one???
DECLARE @@AttachMe varchar(5000)
SELECT @@AttachMe = FilesToAttach FROM TableAttach
EXEC master.dbo.xp_sendmail 'email@domain.net',
@message='email text is entered here',
@subject='TestSendingAttachments',
@attachments=@@AttachMe
May 12, 2006 at 6:19 am
The problem is that your SELECT statement is replacing the value of @@AttachMe with each row.
Try this instead (replacing the semicolon with whatever character should separate one filename from the next):
DECLARE @@AttachMe varchar(5000)
SELECT @@AttachMe = @@AttachMe + ';' + FilesToAttach FROM TableAttach
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply