I'm trying to send e-mails with SQL Server. I found a couple of example but none are working for me. I'm sure the examples are right, I'm just wondering if I have something to set up in SQL Server to "accept" sending e-mails? Right now, I'm running the examples and I receive no errors. It looks like the message was sent but I never received it. Thanks Real Drouin Paromail.com real.drouin@paromail.com
Are these mail programs using SMTP mail? If you are then all you need is a correctly configured SMTP server which is likely already set up. Sonfirm with your network admin. If you are talking about SQL Mail check out BOL for help configuring this. There's a fair bit to do.
See where this works 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
COuld you post those couple of examples you've taken? Satya SKJ Moderator http://www.SQL-Server-Performance.Com/forum This posting is provided “AS IS†with no rights for the sake of knowledge sharing.