MS SQL Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesMS SQL Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old October 25th, 2004, 04:06 AM
esthera esthera is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Posts: 138 esthera User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 2 m 11 sec
Reputation Power: 6
send email from sql server

How can I send an email from sql server.

I tried the following code which gives me no errors but doesn't send the email.

Code:
CREATE Procedure sp_SMTPMail	@SenderName varchar(100),	@SenderAddress varchar(100),	@RecipientName varchar(100),	@RecipientAddress varchar(100),	@Subject varchar(200),	@Body varchar(8000)AS		SET nocount on		declare @oMail int --Object reference	declare @resultcode int		EXEC @resultcode = sp_OACreate 'CDONTS.NewMail', @oMail OUT		if @resultcode = 0	BEGIN		EXEC @resultcode = sp_OASetProperty @oMail, 'From', @SenderAddress		EXEC @resultcode = sp_OASetProperty @oMail, 'To', @RecipientAddress		EXEC @resultcode = sp_OASetProperty @oMail, 'Subject', @Subject		EXEC @resultcode = sp_OASetProperty @oMail, 'Body', @Body			EXEC @resultcode = sp_OAMethod @oMail, 'Send', NULL			EXEC sp_OADestroy @oMail	END		SET nocount off GO
GO


Can anyone recommend a solution to send email from sql server?

Reply With Quote
  #2  
Old October 25th, 2004, 08:11 AM
Al_Dev's Avatar
Al_Dev Al_Dev is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2003
Posts: 105 Al_Dev User rank is Private First Class (20 - 50 Reputation Level)Al_Dev User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 7 h 32 m 21 sec
Reputation Power: 6
Send a message via AIM to Al_Dev
Did you run that create script as is? one line.

There's a comment in there that negates the whole thing if you run the script as one long line. Format the proc to line by line, re-create it, and try again.
if that still doesn't work, there may be security issues involved with the exchange or smtp server you are using.

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesMS SQL Development > send email from sql server


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway