I'm trying to send a email with attached file using the sp_send_dbmail store procedure (SQL Server 2005). The file is stored into a field of a data base table. I succeed to send the mail with the attached file, the recipient correctly receives it (and the attached file) but doesn't succeed in opening the file: for example if the file is a .doc the Word application doesn't read it. In order to retrieve the content of the attached file I set the @query parameter of the sp_send_dbmail store procedure with 'SELECT Data FROM AttachmentData WHERE AttachmentId = 78'. The type of the field 'Data' is varbinary(max). The values of the other parameters are: @profile_name = @MyProfileName, @recipients = @To, @copy_recipients = @Cc, @subject = @Subj, @body = @Content, @query = @selectAtt, @query_result_header = 0, @attach_query_result_as_file = 1, @query_attachment_filename = @MyFileName, @exclude_query_output = 1, @query_no_truncate = 1, If the file to attach is a txt file and the @query parameter is set with 'SELECT CAST(Data AS varchar(MAX)) FROM TEST_ATTACH.dbo.AttachmentData WHERE AttachmentId = 56' the mail recipient will be able to open the file. For the other file tipe (.gif, .doc, .pdf ecc) I try to modify the @query parameter in order to cast to the varbinary type but it doesn't work: the recipient is not able to open the attached file. Can help me? Have a Nice day! Thanks Much.