send_dbmail error. Attachment file is invalid

  • Hi,

    i'm trying to send an email to myself (internal ) and also to someone external of the company.

    I want to send an attachment and i've been looking at the following link but when i try it says

    'attachment file https://mysite.com/documents/2000/docname.pdf is invalid'

    i've copied and paste the file name into my browser and it definetely points to a document.

    declare @subjectline varchar(100) = 'test subject',

    @newbody varchar(100) = 'testbody',

    @myattachment varchar(max) = 'https://mysite.com/documents/2000/docname.pdf'

    ,@hc int

    --the below is a call to my stored procedure which in turn calls the send_dbmail stored procedure

    EXEC sp_Sys_SendMail_attachment 'myemailaddress@me.com',@subjectLine,@NewBody,

    @attachment = @myattachment,

    @RetVal = @hc OUTPUT

    http://technet.microsoft.com/en-us/library/ms190307.aspx

    can anyone see what i'm doing wrong?

    thanks

  • This was removed by the editor as SPAM

  • i had not seen anyone try that before...getting a file from an url.

    I'm awful sure the retrieving of an attachment is a file operation only, and the file must exist on the server or on a network share the server can access...i don't think the sp_send_mail will download a remote file and then attach it.

    am i right?

    http://technet.microsoft.com/en-us/library/ms190307.aspx


    [ @file_attachments= ] 'file_attachments'

    Is a semicolon-delimited list of file names to attach to the e-mail message. Files in the list must be specified as absolute paths. The attachments list is of type nvarchar(max). By default, Database Mail limits file attachments to 1 MB per file. For more information, see Database Mail Configuration Wizard.

    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!

  • I think you must be right.

    i ended up with the following:

    declare @subjectline varchar(100) = 'test subject',

    @newbody varchar(100) = 'testbody',

    @myattachment varchar(max) = '//server/folder/2000/docname.pdf'

    ,@hc int

    --the below is a call to my stored procedure which in turn calls the send_dbmail stored procedure

    EXEC sp_Sys_SendMail_attachment 'myemailaddress@me.com',@subjectLine,@NewBody,

    @attachment = @myattachment,

    @RetVal = @hc OUTPUT

    thanks 😎

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

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