Sending mail using CDONTS and Sql Server

  • Comments posted to this topic are about the item Sending mail using CDONTS and Sql Server

  • Will this still work on a server running in 64 bit.

    I am getting this message

    SQL Mail does not work with the 64-bit version of SQL Server Microsoft SQL Error 17938

  • whats is CDONTS and it will send query result in mail?

  • I could not get Database Mail to work on a Server so I tried CDONTS.

    I used the following code:

    DECLARE @From varchar(100)

    DECLARE @To varchar(100)

    DECLARE @Subject varchar(100)

    DECLARE @Body varchar(4000)

    DECLARE @cc varchar(100)

    DECLARE @BCC varchar(100)

    SET @cc = Null

    SET @BCC = Null

    DECLARE @MailID int

    DECLARE @hr int

    SET @From = 'jblow@.com'

    SET @To = 'jblow@.com'

    SET @Subject = 'Testing'

    SET @Body = 'Testing'

    EXEC @hr = sp_OACreate 'CDONTS.NewMail', @MailID OUT

    EXEC @hr = sp_OASetProperty @MailID, 'From',@From

    EXEC @hr = sp_OASetProperty @MailID, 'Body', @Body

    EXEC @hr = sp_OASetProperty @MailID, 'BCC',@BCC

    EXEC @hr = sp_OASetProperty @MailID, 'CC', @cc

    EXEC @hr = sp_OASetProperty @MailID, 'Subject', @Subject

    EXEC @hr = sp_OASetProperty @MailID, 'To', @To

    EXEC @hr = sp_OAMethod @MailID, 'Send', NULL

    EXEC @hr = sp_OADestroy @MailID

    I get command executed sucessfully.

    I can sent via telnet but no other method works.

    Any suggestions?

    For better, quicker answers on T-SQL questions, click on the following...
    http://www.sqlservercentral.com/articles/Best+Practices/61537/

    For better answers on performance questions, click on the following...
    http://www.sqlservercentral.com/articles/SQLServerCentral/66909/

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply