I am trying (unsuccessfully) to use sp_send_dbmail (Transact-SQL).
The @recipients value is said to be a semicolon-delimited list of e-mail addresses to send the message to.
So, in my data table’s Email column, all I should have to do is update the row to send to multiple recipients:
Old: JoeP@jp2code.net
New: JoeP@jp2code.net; personB@jp2code.net
There are no errors, but then there is no email going out.
The code I use to call sp_send_dbmail is unchanged in my stored procedure:
IF (0 < (SELECT COUNT(ID) FROM #Email)) BEGIN
SELECT TOP 1 @ID=ID, @email=Email FROM #Email
EXEC msdb.dbo.sp_send_dbmail @recipients=@email, @subject=@subj, @body=@html, @body_format='HTML', @from_address='no-reply@jp2code.net', @reply_to=@email;
DELETE #Email WHERE @email=Email
END
So, what is wrong?
I may have found the issue…
[ @reply_to= ] ‘reply_to’
Is the value of the ‘reply to address’ of the email message. It accepts only one email address as a valid value. This is an optional parameter used to override the settings in the mail profile. This parameter is of type varchar(MAX). SMTP secuirty settings determine if these overrides are accepted. If no parameter is specified, the default is NULL.
This explains why it worked with a single address, but doesn’t work with multiple addresses.