unable to send email if i add <br> tag

I am trying to send an email using asp.net 1.1
My web form has a textarea field, which allows typing address using the 'enter' key for line feed.
In the code behind, i am replacing chr(13) with "<BR>". The code is as below:
pstrEmailBody = pstrEmailBody & "<td>" & Replace(txaAddress.Value, Chr(13), "<br>") & "</td>"

when i see the contents of pstrEmailBody in the immediate window, i see the breaks correctly. i also copied the output into an HTML file, and it is perfect. However, when sending out the email, i get the above error. If i remove the replace part, then the email goes correctly, but the address comes on a single line in the email.

I have also attached the email function. see below:

Public Sub SendMail(ByVal EmailBody As String, ByVal FirstName As String, ByVal LastName As String)
        Dim objMail As Mail.MailMessage
        Dim objSMTPMail As SmtpMail
        Dim pstrError

        Try
            objMail = New Mail.MailMessage
            objMail.From = "riaz@sanginfo.com"
            objMail.To = "riaz@sanginfo.com"
            objMail.BodyFormat = MailFormat.Html
            objMail.Body = EmailBody
            objMail.Subject = "New Tutor Application - " & FirstName & " " & LastName
            objSMTPMail.SmtpServer = ConfigurationSettings.AppSettings.Item("SMTPMailServer")
            objSMTPMail.Send(objMail)
        Catch ex As Exception
            pstrError = ex.ToString()
        Finally
            If Not objSMTPMail Is Nothing Then objSMTPMail = Nothing
            If Not objMail Is Nothing Then objMail = Nothing
        End Try
    End Sub
RTKHOTAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

appariCommented:

what error are you getting?
0
RTKHOTAuthor Commented:
Visual Basic .Net, IE7, Run-time exception thrown : System.Web.HttpException - Could not access 'CDO.Message' object
0
Sachintana DissanayakeSenior Web DeveloperCommented:
Replace this line with Environment.NewLine,



pstrEmailBody = pstrEmailBody & "<td>" & Replace(txaAddress.Value, Environment.NewLine , "<br>") & "</td>"

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Introducing Cloud Class® training courses

Tech changes fast. You can learn faster. That’s why we’re bringing professional training courses to Experts Exchange. With a subscription, you can access all the Cloud Class® courses to expand your education, prep for certifications, and get top-notch instructions.

vjc2003Commented:
Looks like it is not a problem with your mail body
The "Could not access 'CDO.Message' object" error could be because the SMTP Server is not
available or might not be configured properly.
You can try with an empty mail body to test this.
0
RTKHOTAuthor Commented:
it work perfectly and the email gets delivered properly if i do not have that replace code. i have not yet tried the environment.newline. i will let you know how it goes. thanks everyone
0
RTKHOTAuthor Commented:
thank you very much.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.