Hi all,
I am creating a stored procedure to send an email and when I execute the SP i get this error:
Msg 14624, Level 16, State 1, Procedure sp_send_dbmail, Line 237
At least one of the following parameters must be specified. "@body, @query, @file_attachments, @subject".
Here is part of my procedure:
DECLARE @live_order_id nvarchar(10),@add_usr varchar (100),@cust_name_id nvarchar(10),@class_name nvarchar(100), @order_id nvarchar(10),@strSubject varchar(100),@file_attachments nvarchar (100), @strBody varchar(4000), @type tinyint, @bitmap char (6), @event_name nvarchar(150), @cursor varchar(25),@event_datetime varchar (100), @section_name varchar (100),@email_addr nvarchar(100),
@name varchar(100),@additional varchar (4000),@recipients varchar(25),@profile_name varchar (25), @num_seats nvarchar (100), @date_entered varchar(100), @fulfilledon varchar(100),@inet_event_description varchar(100),@other_info_3 varchar(100),@acct_id nvarchar (25)
DECLARE UnVerifiedCursor CURSOR FOR
SELECT v_live_inventory.live_order_id, v_returned_inventory.other_info_3, v_live_inventory.inet_event_description, v_live_inventory.section_name,
v_returned_inventory.add_usr, v_live_inventory.num_seats, v_returned_inventory.acct_id, v_returned_inventory.class_name,
AT_trans_for_emailTrigger.email_addr, AT_trans_for_emailTrigger.cust_name_id, premclub.name_first + ' ' + premclub.name_last AS name
FROM v_returned_inventory INNER JOIN
v_live_inventory ON LEFT(v_returned_inventory.event_name, 6) = LEFT(v_live_inventory.event_name, 6) AND
v_returned_inventory.orderNumber = v_live_inventory.other_info_1 INNER JOIN
AT_trans_for_emailTrigger ON v_returned_inventory.order_id = AT_trans_for_emailTrigger.order_id LEFT OUTER JOIN
OPENQUERY(premclub, 'select name_first, name_last, cust_name_id from dba.v_cust_name') AS premclub ON
AT_trans_for_emailTrigger.cust_name_id = premclub.cust_name_id
GROUP BY v_returned_inventory.acct_id, v_live_inventory.live_order_id, v_live_inventory.section_name, v_live_inventory.inet_event_description,
v_returned_inventory.other_info_3, v_live_inventory.num_seats, v_returned_inventory.add_usr, v_returned_inventory.class_name,
AT_trans_for_emailTrigger.email_addr, AT_trans_for_emailTrigger.cust_name_id, premclub.name_first + ' ' + premclub.name_last
HAVING (v_returned_inventory.class_name = 'INT_BIRTHDAY')
--open cursor
OPEN UnVerifiedCursor
FETCH NEXT FROM UnVerifiedCursor INTO @order_id,@other_info_3,@inet_event_description,@section_name,@add_usr,@num_seats,@acct_id,@class_name,@email_addr,@cust_name_id,@name
WHILE @@FETCH_STATUS = 0
BEGIN
BEGIN
SET @strBody = 'Birthday Suite Notification
Addtional Notes:' + SPACE(1) + @other_info_3 + SPACE(1) +'
Event Name:' + SPACE(1) + @inet_event_description + SPACE(1) + '
Event Date:' + SPACE(1) + CONVERT(VARCHAR,@event_datetime,120) + SPACE(1) + '
Section:' + SPACE(1) + @section_name + SPACE(1) + '
'+'Order Information:' +'
--------------------------------------------------------------------------------
Name:' + SPACE(1) + @name + SPACE(1) + '
Email address:' + SPACE(1) + @email_addr + SPACE(1) +'
Order ID:' + SPACE(1) + @order_id + SPACE(1) +'
Acct ID:' + SPACE(1) + @acct_id + SPACE(1) +'
--------------------------------------------------------------------------------'
SET @strSubject = 'BIRTHDAY SUITE '+ @event_datetime + SPACE(1)+' '
-- EXEC sp_send_cdontsmail @strFrom, @email_addr, @strSubject, @strBody
EXEC msdb.dbo.sp_send_dbmail
@profile_name = 'Orders_at_TDGarden_profile',
@recipients = 'test@test.com',
@Body = @strBody,
@Subject = @strSubject
END
FETCH NEXT FROM UnVerifiedCursor INTO @order_id,@other_info_3,@inet_event_description,@section_name,@add_usr,@num_seats,@acct_id,@class_name,@email_addr,@cust_name_id,@name
END
-- close cursor
CLOSE UnVerifiedCursor
DEALLOCATE UnVerifiedCursor
Please let me know if you can help if you need any additional information. Thanks!
I am creating a stored procedure to send an email and when I execute the SP i get this error:
Msg 14624, Level 16, State 1, Procedure sp_send_dbmail, Line 237
At least one of the following parameters must be specified. "@body, @query, @file_attachments, @subject".
Here is part of my procedure:
DECLARE @live_order_id nvarchar(10),@add_usr varchar (100),@cust_name_id nvarchar(10),@class_name nvarchar(100), @order_id nvarchar(10),@strSubject varchar(100),@file_attachments nvarchar (100), @strBody varchar(4000), @type tinyint, @bitmap char (6), @event_name nvarchar(150), @cursor varchar(25),@event_datetime varchar (100), @section_name varchar (100),@email_addr nvarchar(100),
@name varchar(100),@additional varchar (4000),@recipients varchar(25),@profile_name varchar (25), @num_seats nvarchar (100), @date_entered varchar(100), @fulfilledon varchar(100),@inet_event_description varchar(100),@other_info_3 varchar(100),@acct_id nvarchar (25)
DECLARE UnVerifiedCursor CURSOR FOR
SELECT v_live_inventory.live_order_id, v_returned_inventory.other_info_3, v_live_inventory.inet_event_description, v_live_inventory.section_name,
v_returned_inventory.add_usr, v_live_inventory.num_seats, v_returned_inventory.acct_id, v_returned_inventory.class_name,
AT_trans_for_emailTrigger.email_addr, AT_trans_for_emailTrigger.cust_name_id, premclub.name_first + ' ' + premclub.name_last AS name
FROM v_returned_inventory INNER JOIN
v_live_inventory ON LEFT(v_returned_inventory.event_name, 6) = LEFT(v_live_inventory.event_name, 6) AND
v_returned_inventory.orderNumber = v_live_inventory.other_info_1 INNER JOIN
AT_trans_for_emailTrigger ON v_returned_inventory.order_id = AT_trans_for_emailTrigger.order_id LEFT OUTER JOIN
OPENQUERY(premclub, 'select name_first, name_last, cust_name_id from dba.v_cust_name') AS premclub ON
AT_trans_for_emailTrigger.cust_name_id = premclub.cust_name_id
GROUP BY v_returned_inventory.acct_id, v_live_inventory.live_order_id, v_live_inventory.section_name, v_live_inventory.inet_event_description,
v_returned_inventory.other_info_3, v_live_inventory.num_seats, v_returned_inventory.add_usr, v_returned_inventory.class_name,
AT_trans_for_emailTrigger.email_addr, AT_trans_for_emailTrigger.cust_name_id, premclub.name_first + ' ' + premclub.name_last
HAVING (v_returned_inventory.class_name = 'INT_BIRTHDAY')
--open cursor
OPEN UnVerifiedCursor
FETCH NEXT FROM UnVerifiedCursor INTO @order_id,@other_info_3,@inet_event_description,@section_name,@add_usr,@num_seats,@acct_id,@class_name,@email_addr,@cust_name_id,@name
WHILE @@FETCH_STATUS = 0
BEGIN
BEGIN
SET @strBody = 'Birthday Suite Notification
Addtional Notes:' + SPACE(1) + @other_info_3 + SPACE(1) +'
Event Name:' + SPACE(1) + @inet_event_description + SPACE(1) + '
Event Date:' + SPACE(1) + CONVERT(VARCHAR,@event_datetime,120) + SPACE(1) + '
Section:' + SPACE(1) + @section_name + SPACE(1) + '
'+'Order Information:' +'
--------------------------------------------------------------------------------
Name:' + SPACE(1) + @name + SPACE(1) + '
Email address:' + SPACE(1) + @email_addr + SPACE(1) +'
Order ID:' + SPACE(1) + @order_id + SPACE(1) +'
Acct ID:' + SPACE(1) + @acct_id + SPACE(1) +'
--------------------------------------------------------------------------------'
SET @strSubject = 'BIRTHDAY SUITE '+ @event_datetime + SPACE(1)+' '
-- EXEC sp_send_cdontsmail @strFrom, @email_addr, @strSubject, @strBody
EXEC msdb.dbo.sp_send_dbmail
@profile_name = 'Orders_at_TDGarden_profile',
@recipients = 'test@test.com',
@Body = @strBody,
@Subject = @strSubject
END
FETCH NEXT FROM UnVerifiedCursor INTO @order_id,@other_info_3,@inet_event_description,@section_name,@add_usr,@num_seats,@acct_id,@class_name,@email_addr,@cust_name_id,@name
END
-- close cursor
CLOSE UnVerifiedCursor
DEALLOCATE UnVerifiedCursor
Please let me know if you can help if you need any additional information. Thanks!