June 2, 2016 at 12:08 am
Hi
I have this code, which is just a part of my code:
SET @Attachment = @FilePath + @ReportFileName
SELECT
@SQLCommand = 'BCP "SELECT * FROM ##!TableName!" QUERYOUT ' +
@FilePath + @ReportFileName + ' -c -t, -T -S' + @@SERVERNAME
EXEC MASTER..XP_CMDSHELL @SQLCommand
EXEC MASTER..xp_fileexist @Attachment, @FileExistsEmailFlag OUT
IF @FileExistsEmailFlag = 1
BEGIN
EXEC msdb..sp_send_dbmail
@recipients = @Recepients
,@copy_recipients = @cc
,@subject = @EmailSubject
,@file_attachments = @Attachment
,@body_format = 'HTML'
END
That send the attachment, however the files can be bigger. I need to rather place a file in the directory then send email that the file can be found that directory. please help.
June 2, 2016 at 2:09 am
where you kept the file in server particluar directory. and the path is stored in the database ?
if your size is bigger , how you are going compress
June 2, 2016 at 7:07 pm
hoseam (6/2/2016)
HiI have this code, which is just a part of my code:
SET @Attachment = @FilePath + @ReportFileName
SELECT
@SQLCommand = 'BCP "SELECT * FROM ##!TableName!" QUERYOUT ' +
@FilePath + @ReportFileName + ' -c -t, -T -S' + @@SERVERNAME
EXEC MASTER..XP_CMDSHELL @SQLCommand
EXEC MASTER..xp_fileexist @Attachment, @FileExistsEmailFlag OUT
IF @FileExistsEmailFlag = 1
BEGIN
EXEC msdb..sp_send_dbmail
@recipients = @Recepients
,@copy_recipients = @cc
,@subject = @EmailSubject
,@file_attachments = @Attachment
,@body_format = 'HTML'
END
That send the attachment, however the files can be bigger. I need to rather place a file in the directory then send email that the file can be found that directory. please help.
You have the file path and the file name. Concatenate them together along with whatever text you wish to include and use it as the body of the email. Of course, you can take out all references to the attachment.
--Jeff Moden
Change is inevitable... Change for the better is not.
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply