RTRIM

  • hi,

    I have the following code:

    set @to = 'you@test.com'       ---- i have this stmt..........thru debugger i see tht @to has the value 'you@test.com               '

    How do i remove the trailing white space in this case using RTRIM

    Thanks,

    Natalie.

      

  • if the quotes are actually part of your string:

     

    set @to = ''''    + rtrim('you@test.com') + ''''


    Kindest Regards,

    Dennis

  • I'm guessing that @to is defined as char(xx), so it will always be xx long.  Define it as varchar(xx) and the variable will hold only what you stuff in.


    And then again, I might be wrong ...
    David Webb

  • Hi,

    I had it char..... changed it to varchar - in the debugger it shows fine now.

    But then i dont get the email notification.

    DECLARE @msg int

       DECLARE @to varchar(50)

       DECLARE @from varchar(50)

       DECLARE @subject varchar(50)

       DECLARE @smtpsrvr varchar(50)

    DECLARE @body varchar(50)

       SET @to =  'you@test.com'

       SET @from = --from addr

       SET @subject = 'Subject 1'

       SET @body = ---body goes here

       SET @smtpsrvr = --smtpsrvr

          

       EXEC sp_OACreate 'CDO.Message', @msg OUT

       EXEC sp_OASetProperty @msg, 'Configuration.fields("<A href="http://schemas.microsoft.com/cdo/configuration/sendusing&quot.Value','2'">http://schemas.microsoft.com/cdo/configuration/sendusing").Value','2'

       EXEC sp_OASetProperty @msg, 'Configuration.fields("<A href="http://schemas.microsoft.com/cdo/configuration/smtpserver&quot.Value'">http://schemas.microsoft.com/cdo/configuration/smtpserver").Value', @smtpsrvr

       EXEC sp_OAMethod @msg, 'Configuration.Fields.Update', null

       EXEC sp_OASetProperty @msg, 'To', @To

        EXEC sp_OASetProperty @msg, 'From', @From

        EXEC sp_OASetProperty @msg, 'Subject', @Subject

       EXEC sp_OASetProperty @msg, 'TextBody', @Body

        EXEC sp_OAMethod @msg, 'Send', NULL

     

       EXEC sp_OADestroy @Msg

  • Hello Natalie,

    I have checked by executing the code and it is working fine.

    Thanks and have a great day!!!


    Lucky

  • Hi,

    I am still not able to receive the mails - do i have to configure outlook to receive mails from sql server

    Let me know.

    Thnx.

     

  • No outlook is a mail client and doesn't require any configuration to receive emails.

    SQL server on the other hand does require a MAPI profile to be able to send emails. 

    Have you configured SQL Server ?

     

     

  • Have you set @smtpsrvr to a valid mail server address?

    Does the mail server allow you to use it to send emails?

    If not on the same LAN, is the firewall open to you sending emails?

    Tim S

  • Hi,

    @smtpsrvr is set to a valid mail server address.

    i am able to send mails and receive in general.

    I did not have from addr mentioned earlier - but then i was able to execute and i got the mail. But then when i try it again - say by changing the body content - and execute - i am not receiving the mail.

    Anyways - will play around with it more.

    Thnx

  • I am able to receive the email notifications.

    It was just that i didnt have @From in my code....... guess all statements are required for the email notifications to get through

    Thnx.

     

Viewing 10 posts - 1 through 9 (of 9 total)

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