January 14, 2016 at 9:03 pm
I have a list of email address. Previously I use sp_send_dbmail and adhoc doing it one by one. The list is getting longer.
Any suggestion how can I send email from condition?
Example:
Code emailaddress
case when code='A' then send it to a@abc.com
case when code='B' then send it to b@abc.com
Is this possible?
Or I still need to do one by one?
January 14, 2016 at 9:55 pm
You need to call sp_send_dbmail once for every email you want to send.
There are no special teachers of virtue, because virtue is taught by the whole community.
--Plato
January 14, 2016 at 10:04 pm
There are no other way?
As the list are growing.. Feel like not efficient doing it one by one.
January 14, 2016 at 10:28 pm
Calling the proc once for each email is the supported way. If you need bulk mailer capabilities and performance then Database Mail might not be right for you.
There are no special teachers of virtue, because virtue is taught by the whole community.
--Plato
January 15, 2016 at 1:02 am
I have like 1000 recipients. I need to do that 1000 times?
Any idea how can I solve this?
January 15, 2016 at 1:15 am
1000 is actually not much at all. Yes, again, you need to call the proc 1000 times to send a separate email to eaxh recipient. Do you have the emails stored in a table? Writing code to call the proc once for each email is not too difficult.
There are no special teachers of virtue, because virtue is taught by the whole community.
--Plato
January 15, 2016 at 1:23 am
Is it the exact same message (unpersonalised) that you want to send to each recipient. You can send the same message to multiple recipients, so why not build the list first and then pass it to the @recipients parameter?
John
January 15, 2016 at 1:29 am
Same store proc but different parameter. Results send to different recipients.
exec store proc A 'henry','getdate()'
send to henry@gmail.com
exec store proc B 'george','getdate()'
send to george@gmail.com
Doing this 1000 times? Any suggestion and guidance.
January 15, 2016 at 1:40 am
Typically looping and cursors are to be avoided but in cases where you must call a procedure once for each row for a relatively small number of rows it is warranted.
There are no special teachers of virtue, because virtue is taught by the whole community.
--Plato
Viewing 9 posts - 1 through 8 (of 8 total)
You must be logged in to reply to this topic. Login to reply