hi,
im saving the document content in a table with IMAGE datatype.
when im fetching the content from the table and passing into @query parameter to send mail using
sp_send_dbmail:
problems 1.only txt files will be able to open
problem 2.pdf,docx,xls im unable to open,its showing msg like content corrupted,'i think encoding defect...
so i searched in net ,found using the BCP to convert the file formats, so i used code like
select @sql= 'bcp "select cast(cast(documentContent as varbinary(max)) as varchar(max)) from tbl_CarDocuments_Log where Id = 5018" queryout ' + @Filename + ' -T -n -CACP -S10.98.104.28'
exec master..xp_cmdshell @sql
and then executing the proc below
EXEC msdb.dbo.sp_send_dbmail
@from_address = 'dsfsd@fsdf.com',
@recipients= 'fsdfsd@dfs.com',
@copy_recipients = fssdf@fsfsd.com',
@subject= 'test',
@body= 'testing' ,
@body_format = 'html',
@file_attachments = @Filename
SET @sql = 'del "' + @Filename + '"'
exec master..xp_cmdshell @sql
my doubt is what contents in @sql which we exectuing master..xp_cmdshell,and how did it converts the exact format of file fetching from table.
where can i write the filename,since im fetching only content