1

I am trying to send pdf attachments in sql email (sql server 2008). Sometimes the attachment is present in the emails , but its corrupt and cannot be opened. Sometime email itself is not going. When I try the same without adding the attachment, emails goes everytime. The attached file is hardly 300 KB and is present in teh server always.

Below is the code which ia m using to send emails.

  EXEC msdb.dbo.sp_send_dbmail                                                                                      
  @profile_name = @Profile,                                                                                     
  @recipients = @EmailTo,                        
  @copy_recipients = '',                                                                
  @subject = @EmailSubject,                                                                                      
  @body = @EmailBody,  
  @file_attachments = @Attachment,-- this will contain the physical file of teh document in database server.                                                                               
  @body_format = 'HTML',                                                                                      
  @execute_query_database = 'DBNAME'       

I am not able to zero in as to what the issue is.

3
  • The problem is almost certainly not in the code you posted here but in the code that is used to populate @Attachment, or possibly in the data that created that data in the first place. Commented Oct 10, 2017 at 19:56
  • @Attachment is nothing but this will contain the physical file of teh document in database server. This is not created programitically. This is a manually created PDF and I can open this PDF as well seperately , so I dont see any issue with the PDF as such Commented Oct 11, 2017 at 0:41
  • Are you 100% certain that the files that are corrupt after being sent are not corrupt as they sit in the folder? I don't know how to help here as it would be nearly impossible to recreate this issue elsewhere. Commented Oct 11, 2017 at 13:09

1 Answer 1

2

The sql mail config had a limit of size of the attachments, hence the error was coming up. Anyways Thanks for your inputs

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.