send attachment in email

  • I have this Proc setup to send a attachment in an email. If I take the file stuff out it sends the email but wont if its there I get error Msg 8145, Level 16, State 1, Procedure sp_send_dbmail, Line 0

    @file_attchments is not a parameter for procedure sp_send_dbmail.

    USE [SMS]

    GO

    /****** Object: StoredProcedure [dbo].[usp_Soccer] Script Date: 10/09/2012 15:01:48 ******/

    SET ANSI_NULLS ON

    GO

    SET QUOTED_IDENTIFIER ON

    GO

    alter PROC [dbo].[usp_Send_File]

    as

    DECLARE ----@TodaysDate date = getdate(),

    @PhoneNumber nvarchar(max),

    @FirstName varchar(25),

    @body nvarchar(MAX),--= ' Soccer '

    @filename nvarchar(MAX)

    DECLARE @Soccer TABLE(ID int IDENTITY(1,1), PhoneNumber nvarchar(MAX), FirstName varchar(25))

    --set Identity_insert [@Soccer] on

    INSERT @Soccer

    SELECT PhoneNumber, FirstName from dbo.Name

    DECLARE @NumberOfSoccer smallint = (SELECT COUNT(*) from @Soccer)

    DECLARE @MinID int

    WHILE @NumberOfSoccer > 0

    BEGIN

    SET @MinID = (SELECT MIN(ID) From @Soccer)

    SET @PhoneNumber = (SELECT PhoneNumber from @Soccer where ID = @MinID)

    set @FirstName = (Select FirstName from @Soccer where ID = @MinID)

    SET @body = 'Soccer Signups ' + @FirstName;

    set @filename = 'C:\test.docx';

    EXECUTE msdb.dbo.sp_send_dbmail

    @subject = 'Soccer',

    @recipients = @PhoneNumber,

    @file_attchments = @filename,

    --@blind_copy_recipients = ***@*****.com; ***@*****.com',

    @body = @body ,

    @profile_name ='Soccer';

    DELETE FROM @Soccer where ID = @MINID

    SET @NumberOfSoccer = @NumberOfSoccer -1

    END

    --END

    RETURN;

  • @file_attachments

  • I knew it was something i was overlooking.

    Thanks

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

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