Body of e-mail cut when using CDONTS from SQL

  • The pretty much same code sends right e-mail from ASP page, but

    this, if sent from SQL server, cuts Body for the message.

    I did verify that SQL sends right query (to MTS?) using SQL Profiler.

    Please help!

    Declare

    @From [VARCHAR](8000) ,

    @To [VARCHAR](8000) ,

    @Subject [VARCHAR](8000),

    @Body [VARCHAR](8000),

    @Importance int ,

    @MailFormat [BIT] ,

    @BodyFormat [BIT]

    Select @From ='Server', @To ='somebody@domain.com,

    @Body= 'Dear Valuable Customer,<BR>Good Afternoon!<BR>Your Request for<i>The Best Candies in the World</i> has been received on the WEB.<BR> You can access it by logging in <a href=http://www.domain.com/>http://www.domain.com/</a&gt; to review your orders. If you see a <FONT color=red>missing</FONT> designation or the reports indicate the previous run date - please hit the refresh key on your browser. If the problem persists, please call Customer Service at the number you've been given immediately for prompt assistance. ',

    @Importance =3,

    @MailFormat =0,

    @BodyFormat =0

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

    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, 'MailFormat', @MailFormat

    EXEC @hr = sp_OASetProperty @object, 'BodyFormat', @BodyFormat

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

    exec @hr = sp_OASetProperty @object, 'Importance', @Importance

    EXEC @hr = sp_OAMethod @object, 'Send'

    EXEC @hr = sp_OADestroy @object

  • Please check for single quotes while storing data in SQL Server(rather any other database). You have used single quotes in between the text that you want to send as mail. Check out the word --- you've.

    Replace single quotes with double single quotes, which should solve your problem.

    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