Database mail issue - Attachment file is invalid -

  • Hi All,

     

    I have an issue with database mail

    When I run this :

     

    USE msdb

    EXEC sp_send_dbmail

      @profile_name='pivotal jobs',

      @recipients='Sarah@abc.com',

      @subject='Test Attachment',

      @body='An attachment has been included in this email',

     @file_attachments='C:\abc.txt'

     

     

    The error comes up “ Attachment file C:\abc.txt is invalid

     

    But if I remove the file_attachment , it works well ( I got theemail )

     

    I checked the permission for (hostname\users ) , it was only forRead and Read&execute only so I changed it into Full control butunfortunately The error is still there

     

    I would really appreciate for the feedback

    Cheers

  • Try removing the (all) quotes around the file name and path in the @file_attachments and retry.

  • Is this file really in the root of C: ?  If so it could be a permissions issue.

  • also, the attachment has to be accessible to the SERVER; so if the file is on the C: drive of your laptop, and the server is a different machine than your laptop,it will not be found.
    if it is network accessible, a unc path like '\\CentralFileServer\Documents\Lowell\Attachments\mydocument.docx' is a better example.

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

  • Thanks for the reply all . I would check the permission issue

    Cheers

  • When you check the permissions, make sure you look for the account under which the SQL statement is running.  That's the account that needs file system permissions.

  • Ed Wagner - Wednesday, May 17, 2017 6:07 PM

    When you check the permissions, make sure you look for the account under which the SQL statement is running.  That's the account that needs file system permissions.

    I don't get what you mean mate . Do u mean if I run sql statement using my account so my account need file system permission ?
    but again what is file system permission ?

  • WhiteLotus - Wednesday, May 17, 2017 6:13 PM

    Ed Wagner - Wednesday, May 17, 2017 6:07 PM

    When you check the permissions, make sure you look for the account under which the SQL statement is running.  That's the account that needs file system permissions.

    I don't get what you mean mate . Do u mean if I run sql statement using my account so my account need file system permission ?
    but again what is file system permission ?

    You want to attach a file to an email you're sending from SQL Server.  SQL Server runs on the server.  The file you want to attach has to be visible to the server.  The security context in which the SQL executes needs permission to access the file, wherever it is.  This is done with file system permissions.  On the server, go to the directory where the file is and make sure the account has the proper permissions on the Security tab of the Properties dialog.

    If you're running it as yourself, you need permissions to the file system.  If the SQL Agent is running the statement, the service account needs the permissions.

  • Ed Wagner - Wednesday, May 17, 2017 6:37 PM

    WhiteLotus - Wednesday, May 17, 2017 6:13 PM

    Ed Wagner - Wednesday, May 17, 2017 6:07 PM

    When you check the permissions, make sure you look for the account under which the SQL statement is running.  That's the account that needs file system permissions.

    I don't get what you mean mate . Do u mean if I run sql statement using my account so my account need file system permission ?
    but again what is file system permission ?

    You want to attach a file to an email you're sending from SQL Server.  SQL Server runs on the server.  The file you want to attach has to be visible to the server.  The security context in which the SQL executes needs permission to access the file, wherever it is.  This is done with file system permissions.  On the server, go to the directory where the file is and make sure the account has the proper permissions on the Security tab of the Properties dialog.

    If you're running it as yourself, you need permissions to the file system.  If the SQL Agent is running the statement, the service account needs the permissions.

    thanks . will try

Viewing 9 posts - 1 through 8 (of 8 total)

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