sp_senddbmail with attachment

  • I have a file on my local drive c:\mail.txt; I want to send this file as attachment by sp_sendmail

    I am connecting to a different server instance and running this code

    EXEC msdb.dbo.sp_send_dbmail

    @profile_name = 'profile',

    @recipients = 'rec@mycompany.com',

    @subject = 'data load report',

    @body = 'Data Loaded successfully.',

    @file_attachments = N'\\localServer\C$\Mail.txt',

    @body_format = 'HTML';

    And I am getting this error

    Msg 22051, Level 16, State 1, Line 0

    Attachment file \\localServer\C$\Mail.txt is invalid.

    anyone has idea

    Thanks

  • I think that you do not have rights to the given folder, all works for me.

    I received the same error when at me not was the rights

  • If changing the Rights doesn't work, you might want to try creating a named shared instead of using the hidden C$ share.

Viewing 3 posts - 1 through 2 (of 2 total)

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