Having given up with xp_sendmail, I'm using CDONTS to send out mails. A script (I'm running in Query Analyser) that uses xp_readmail to process the contents of an Outlook inbox (it basically reads emails, enters them into the database, and sends them out to a list of users), now contains the following call to another stored proc (among other things):

exec forumtest.dbo.SP_CDONTS_NewMail_Send
@from='[email removed to outwit nasty spammers]',
@to=@em2,
@subject=@sbj2,
@body=@bdy2


The stored_proc SP_CDONTS_NewMail_Send looks like this:

Code:
CREATE PROCEDURE SP_CDONTS_NewMail_Send
    @from VARCHAR(8000),
    @to VARCHAR(8000),
    @subject VARCHAR(8000),
    @body VARCHAR(8000)

AS

DECLARE @result INT
DECLARE @object INT

PRINT 'Creating the CDONTS.NewMail object'
EXEC @result = sp_OACreate 'CDONTS.NewMail', @object OUTPUT
IF @result <> 0
BEGIN
    PRINT 'sp_OACreate Failed'
    RETURN @result
END

PRINT 'Sending the message using the Send method'
PRINT @from
PRINT @to
PRINT @subject
PRINT @body
EXEC @result = sp_OAMethod @object, 'Send', NULL, @from, @to, @subject, @body
IF @result <> 0
BEGIN
    PRINT 'sp_OAMethod Failed'
	
	DECLARE @output varchar(255)
	DECLARE @hr int
	DECLARE @source varchar(255)
	DECLARE @description varchar(255)
	PRINT 'Getting Error Information... '
	EXEC @hr = sp_OAGetErrorInfo @object, @source OUT, @description OUT
	IF @hr=0
	BEGIN
    		SELECT @output = '  Source: ' + @source
    		PRINT @output
    		SELECT @output = '  Description: ' + @description
    		PRINT @output
	END
	ELSE
	BEGIN
    		PRINT '  sp_OAGetErrorInfo failed.'
    	RETURN
END    


    RETURN @result
END

PRINT 'Destroying the CDONTS.NewMail object'
EXEC @result = sp_OADestroy @object
IF @result <> 0
BEGIN
    PRINT 'sp_OADestroy Failed'
    RETURN @result
END

RETURN 0
GO

The problem is that sp_OAMethod is failing. It then prints "Getting Error Information... ", but follows this with a couple of blank lines. I don't know why. It's printing the @to, @from, @subject and @body fine; they look ok, but I need to know why sp_OAMethod is failing and before that I need sp_OAGetErrorInfo to actually return me some useful information about the error.