Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CDONTS

Status
Not open for further replies.

SSesham

Programmer
Feb 26, 2004
17
US
I'm using 'CDONTS' com object in a stored procedure to send the email. The same script works on the servers with 'sql and windows authentication' BUT does not work on servers with just 'windows only' authentication mode!
no errors while executing the procedure and @hr returns a 0 BUT no email is sent!!

Any suggestions please..

CREATE PROCEDURE dbo.spi_email_backupstatus
@subject varchar(255) = 'From ME..',
@body varchar(255) = 'Procedure spi_email_backupstatus has executed.',
@to varchar(50) = 'ME@MYCOMPANY.com',
@from varchar(50) = 'ME@MYCOMPANY.com'
AS
BEGIN
DECLARE @object int
DECLARE @hr int -- "hr" stands for HResult, a standard error in COM
DECLARE @property varchar(255)
DECLARE @return varchar(255)
DECLARE @src varchar(255), @desc varchar(255) -- Used for error messages

-- Create a com object. This is really a Microsoft supplied .dll
EXEC @hr = sp_OACreate 'CDONTS.Newmail', @object OUT
IF @hr <> 0
BEGIN
EXEC sp_OAGetErrorInfo @object, @src OUT, @desc OUT
SELECT hr=convert(varbinary(4),@hr), Source=@src, Description=@desc
RETURN
END
Else
print @hr

-- Set this object's properties.
EXEC @hr = sp_OASetProperty @object, 'from', @from
EXEC @hr = sp_OASetProperty @object, 'to', @to
EXEC @hr = sp_OASetProperty @object, 'subject',@subject
EXEC @hr = sp_OASetProperty @object, 'body', @body

-- Call a method on the object.
EXEC @hr = sp_OAMethod @object, 'send', NULL
IF @hr <> 0
BEGIN
EXEC sp_OAGetErrorInfo @object, @src OUT, @desc OUT
SELECT hr=convert(varbinary(4),@hr), Source=@src, Description=@desc
RETURN
END
Else
print @hr
END
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top