Please start any new threads on our new site at 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)
 sql mail xp_processmail

Author  Topic 

Posting Yak Master

229 Posts

Posted - 2005-08-02 : 03:30:43
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?

Premature Yak Congratulator

22864 Posts

Posted - 2005-08-02 : 04:07:29
Try this
@From varchar(255),
@To varchar(255),
@Message varchar(8000),
@Subject varchar(255))

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


Failing to plan is Planning to fail
Go to Top of Page

- Advertisement -