Sending mail using CDONTS and Sql Server

  • SQL Lover

    SSC Rookie

    Points: 44

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

  • Curryk

    Grasshopper

    Points: 17

    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

  • logicinside22

    SSCrazy Eights

    Points: 9617

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

    Aim to inspire rather than to teach.
    SQL Server DBA

  • Welsh Corgi

    SSC Guru

    Points: 116520

    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 4 (of 4 total)

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