SSIS sp_sendmail Attach Excel File

  • I am getting an file is invalid with both the server and local drives.

    I have tried it with and without the declare and set. Not sure what I am doing

    wrong in this SSIS package.

    DECLARE @attach nvarchar(50)

    --SET @attach = '\\Server\D$\Temp\ShipCompBrand.xlsx'

    SET @attach = 'C:\Temp\ShipCompBrand.xlsx'

    EXEC msdb.dbo.sp_send_dbmail

    @profile_name = 'Sql2008_Email_Profile',

    @recipients = 'jjoseph@pabst.com',

    @body = 'Test Attachment',

    @file_attachments = @attach

  • What size is the file? Compare it to the max file size when you run this command

    EXEC msdb.dbo.sysmail_help_configure_sp ;

    Does the user the SQL Services is running under have access to thefolder?

  • Yes the user has permissions to the drive directory.

    MaxFileSize1000000Default maximum file size

    File Size only 12KB

  • Which version of SSIS are you using?

    The information posted at this URL might help you to resolve the issue:

    https://connect.microsoft.com/SQLServer/feedback/details/552940/sp-send-dbmail-throws-error-22051-file-is-invalid-when-attaching-files-from-a-share-unc-notation

  • This sounds like a permissions error - is there an error code?

    I would check:

    - Does the user account running the package have access to the mail profile

    - Does the sql server engine account have access to the file

    Is there a real need to do this using a SQL task? Can you not do it using a send mail task?

Viewing 5 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic. Login to reply