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.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Sending Email in SQL Server

Author  Topic 

Ranjit.ileni
Posting Yak Master

183 Posts

Posted - 2013-02-09 : 01:49:53
Hi Experts,


if I run one Query then I will get this result:
Assume,
select responsibleprovider ,emailaddress from table1
responsibleprovider emailaddress
aaaa, bbbbb aaaar@uphs.upenn.edu
ddddd, Pppp ddddp@uphs.upenn.edu



if I run another query I get this result:
Assume,
select Count ,responsibleprovider from tablereport

Count responsibleprovider
6 aaaa, bbbbb
8 ddddd, Pppp

I need to send this people email about the number of reports waiting for them (knowing their email address from the previous SQL):

For example, contact Email will get email: You have 1 report
aaaa, bbbbb will get email: You have 4 reports

I am new to Mail functionality in SQL Server ,
Could you please advice me , how to send an mail to repective preoviders with some text.

Thanks!

--Irk

jackv
Master Smack Fu Yak Hacker

2179 Posts

Posted - 2013-02-09 : 06:52:34
SQL Server comes with Database Mail. Use this article to assist in setting up Database Mail , which will allow you to send email from within your sql statements. You will need a valid smtp address to which you can point
http://www.sqlserver-dba.com/2011/01/set-up-database-mail-on-sql-server-2005.html

Jack Vamvas
--------------------
http://www.sqlserver-dba.com
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2013-02-09 : 08:24:56
you can also implement this in ssis using send mail task. Just add a connection to your email server and it will sent the mail.

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -