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
 SQL Server 2000 Forums
 SQL Server Development (2000)
 send email

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2005-01-31 : 08:20:45
koti writes "How can i send a mail through sql server?
Using T-Sql.Can i use xp_sendmail."

eyechart
Master Smack Fu Yak Hacker

3575 Posts

Posted - 2005-01-31 : 11:41:01
you can use xp_sendmail if you have configured a mapi profile on your SQL Server box using the user that SQL Server runs under. BOL has details of how to set this up. In the pre-sp3 era, you had to also install Outlook 2000 or newer to make the email piece work. Now with SP3a the standard Outlook email client will work (from what I am told, I have not tested that however).

If that sounds complicated, it is somewhat. However, there are other ways to send email without using xp_sendmail and having to deal with the mapi profiles. The drawback is that typically, not all features of xp_sendmail are available to you. You'll have to look at the different capabilities of the links below and decide if they will work for you.

Gert Drapers has a great extended sproc at sqldev.net. Here is the direct link http://www.sqldev.net/xp/xpsmtp.htm, here is a wrapper sproc that simplifies usage http://www.sqldev.net/xp/sp_smtp_sendmail.htm. The downside with this implementation is you need to install DLLs on your server (an issue with some DBAs) and it does not support sending a query resultset as the email text.

Another approach is to use the built in collaboration data objects interface of win2k+. Microsoft has a simple implementation on their technet here:

http://support.microsoft.com/default.aspx?scid=kb;en-us;312839&sd=tech

SQLteam linked an article on this awhile back. Good article btw:
http://www.sqlteam.com/item.asp?ItemID=17239

Here is yet another script that uses CDOSYS to send email.
http://www.sqlservercentral.com/scripts/contributions/510.asp



-ec


Go to Top of Page
   

- Advertisement -