Avatar of BravehearT-1326
BravehearT-1326
Flag for United Kingdom of Great Britain and Northern Ireland asked on

Sending mail using SP_SEND_DBMAIL stored proc

Hi experts - got a query regarding sp_send_dbmail stored proc and sending to multiple recipients.

I know that multiple recipients MUST be seperated by a ; (semi-colon) however if someone passes multiple address into the recipients parameter and separates them with a , (comma) is there a record to show that the email addresses that did not receive the email because of the ,(comma) used to separate them.

From what I've checked it always reports as successful as the first recipient is valid but cant see any entry for ones after that.

All help appreciated.
Email ServersMicrosoft SQL Server 2005

Avatar of undefined
Last Comment
BravehearT-1326

8/22/2022 - Mon
Vazgen

I recommend to split @recipients before sending email checking both ',' and ';' separators , then send it one by one for each receipient.
jar3817

How about you just use REPLACE() in your query on recipients input to change any commas to semicolons?

REPLACE(recips,',',';');
ASKER CERTIFIED SOLUTION
BravehearT-1326

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
BravehearT-1326

ASKER
I found that if you search the sysmail_allitems table you can see if someone has accidently used commas instead of semi-colons in their code.  I suppose another way would be to query the email logs from Exchange etc  to see if any unreturned / invalid addresses are seen as well.
select * from sysmail_allitems where recipients like '%,%'

Open in new window

Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy