CDO email stored procedure

  • I am using the following stored procedure to send various emails from my SQL 2000 database. Does anyone have an idea of what modifications I can make to be able to send an attachment with my emails?

    /**********************************

    CREATE PROCEDURE [DBO].[sp_CDOEmail]

    @From varchar(100),

    @to varchar(100),

    @cc varchar(100) = null,

    @BCC varchar(100) = null,

    @Subject varchar(100),

    @body varchar(8000)

    AS

    Declare @MailID int

    Declare @hr int

    EXEC 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

    GO

    ******************************/

    I thought that adding the following line along with a declaration for @attachfile as varchar(100) would allow me to send attachments but it has not.

    EXEC @hr = sp_OASetProperty @MailID, 'AttachFile', @attachfile

  • In JMail you could have used .AddAttachments method to do so. Have not exactly worked with CDONTS EMail Attachments, but that too should work the same way. Dont have any handy reference material as of now. but shall get back to you after I've got some tested code.

    Paras Shah

    Evision Technologies

    Mumbai, India


    Paras Shah
    Evision Technologies
    Mumbai, India

Viewing 2 posts - 1 through 1 (of 1 total)

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