Quote (carteblanche @ Oct 15 2015 07:46pm)
post the script and describe your problem. nobody is going to run it, so we're just eyeballing it. post whatever useful logging you have as well.
I have a script that pulls a file into an email as an attachment and sends it out. It recently has stopped working. The file I am pulling is named "DTH201509240918.xlsx" with the last 4 numbers being random so I use '^.*$'. The files are in the source folder, but I always get "no files found".
ALTER Procedure [dbo].[DSEmail] as begin
declare @to varchar(1000)
,@sub varchar(1000)
,@subdate varchar(10) = CONVERT(Varchar(10),GETDATE(),101)
,@bod varchar(1000)
,@filePath varchar(1000) = '\\source\'
,@fileDate varchar (8) = CONVERT(Varchar(8),GETDATE(),112)
,@attachments varchar(1000)
,@pathAndFile varchar (1000)
Set @attachments = 'DTH' + @fileDate + '^.*$'
Set @pathAndFile = @filePath + @attachments
Set @sub = 'dS Report ' + @subdate
Set @bod = '\\source\' + @attachments
Set @to = 'email@email.com'
IF dbo.fn_FileExists(@pathAndFile) = 1
exec msdb.dbo.sp_send_dbmail
@recipients = @to
,@subject = @sub
,@body = @bod
,@file_attachments = @pathAndFile
ELSE
exec msdb.dbo.sp_send_dbmail
@recipients = @to
,@subject = 'DS Error'
,@body = 'No file was found. Please check \\source\ for today''s file.'
End