Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
imranabdulaziz
Yak Posting Veteran
83 Posts |
Posted - 2008-06-03 : 08:14:05
|
Dear all, i am using sql server 2005.i am facing a scenario where i have to send mail to single or multiple user depending on the query.i tried this stmt to send mail to multiple receipints EXEC msdb.dbo.sp_send_dbmail @profile_name = 'imran' , @recipients= 'imran.khan@bbraun.com;amol.puranik@bbraun.com', @subject = 'Test mail' it succesfully sent mail.Now i want to send mail depending on query. with single employee it is no issue. but if it is more then one employee how can i mail to multiple recipient.That is my question is in this sp to send multiple recepients one has to separates addresses with ; semi colon how can i arreange recipient so that ; comes in between.Thank you. |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-06-03 : 08:16:41
|
Is email addresses coming from some table field? |
|
|
imranabdulaziz
Yak Posting Veteran
83 Posts |
Posted - 2008-06-03 : 08:30:13
|
Yes it is coming from employee_refernce where email id is stored against empcodeTHANK YOU |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-06-03 : 08:33:03
|
WHere will you get information reg whom to be mailed? Or do you want to mail to all employees in table? |
|
|
imranabdulaziz
Yak Posting Veteran
83 Posts |
Posted - 2008-06-03 : 08:35:59
|
EVEN IF U TELL ME HOW TO SEND MAIL TO ALL THE EMPLOYEE MY PROBLEM WILL BE SOLVEDTHANK YOU |
|
|
Ashish Gupta
Starting Member
1 Post |
Posted - 2009-10-28 : 03:56:08
|
Hi Imran , I have gone though the same senario which you are facing, what i did was created a table passed all the email adress in it , and then send the mail picking the email from table, using while loop.use msdbEXEC sp_send_dbmail @profile_name='My gmail live account',@recipients=@email_address,@subject='Test message',@body='hope it helps' Ashish Gupta |
|
|
srikanth448
Starting Member
1 Post |
Posted - 2013-06-25 : 05:41:07
|
Hello All,I do have save requirement of sending multiple emails to users depending on the query.Please can you guide me on this also provide me steps.thanks in advance.... |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2013-06-25 : 05:59:32
|
something likeDECLARE @Receipientlist varchar(8000)SET @ReceipientList = STUFF((SELECT ';' + emailaddress FROM Your query here FOR XML PATH('')),1,1,'')EXEC sp_send_dbmail @profile_name= your email profile in db,@recipients=@Receipientlist,@subject='your subject here',@body='body message here' ... ------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/https://www.facebook.com/VmBlogs |
|
|
|
|
|
|
|