SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 sql mail xp_processmail
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Westley
Posting Yak Master

229 Posts

Posted - 08/02/2005 :  03:30:43  Show Profile  Reply with Quote
Hi all,
Just wondering did anyone can get it going? is it just basicly call this sp? I've got sql mail setup, but everytime when I try to run this, it just gives an error message, so just wondering is there something needs to set before I can use it?
Thanks

madhivanan
Premature Yak Congratulator

India
22744 Posts

Posted - 08/02/2005 :  04:07:29  Show Profile  Send madhivanan a Yahoo! Message  Reply with Quote
Try this
CREATE PROCEDURE SendMail(  
@From varchar(255),    
@To varchar(255),   
@Message varchar(8000),   
@Subject varchar(255))  
 AS   
  
DECLARE @CDO int, @OLEResult int, @Out int   
  
--Create CDONTS.NewMail object   
EXECUTE @OLEResult = sp_OACreate 'CDONTS.NewMail', @CDO OUT   
IF @OLEResult <> 0 PRINT 'CDONTS.NewMail'   
  
  
EXECUTE @OLEResult = sp_OASetProperty @CDO, 'BodyFormat', 0   
EXECUTE @OLEResult = sp_OASetProperty @CDO, 'MailFormat', 0   
  
--Call Send method of the object   
execute @OLEResult = sp_OAMethod @CDO, 'Send', Null, @From, @To, @Subject, @Message, 1 --0 is low 1 is normal   
IF @OLEResult <> 0 PRINT 'Send'   
  
--Destroy CDO   
EXECUTE @OLEResult = sp_OADestroy @CDO   
  
return @OLEResult


Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.5 seconds. Powered By: Snitz Forums 2000