trying to seperate my string with a space, html, or something ??

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • cluce
    New Member
    • Sep 2007
    • 29

    trying to seperate my string with a space, html, or something ??

    Can someone tell me how to manipulate my body string so that when the user semds the email, the info that was in the textboxes are on different lines.

    ex.

    trying to get this:
    Sam doe
    1234 lemon st
    New Orleans, LA

    instead of like this:
    Sam doe 1234 lemon st New Orleans, LA

    Code:
        Inherits System.Web.UI.Page
    
        Protected Sub Wizard1_FinishButtonClick(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.WizardNavigationEventArgs) Handles Wizard1.FinishButtonClick
            Dim body As String
            body = txtComments.Text & _
            txtStreet.Text & _
            txtCity.Text
            SendMail(txtEmail.Text, body)
        End Sub
    
        Private Sub SendMail(ByVal from As String, ByVal body As String)
            Dim mailServerName As String =
            Dim message As MailMessage = New MailMessage(from, "a@ra.com", "feedback", body)
            Dim mailClient As SmtpClient = New SmtpClient
    
            mailClient.Host = mailServerName
            mailClient.Send(message)
            message.Dispose()
        End Sub
    Thanks in advance
  • jeffstl
    Recognized Expert Contributor
    • Feb 2008
    • 432

    #2
    You will want to use the .NET equivalent of the old vbCrLf or carriage return.
    ControlChars.Cr Lf will place a new line in between strings
    Like this:

    Code:
    Inherits System.Web.UI.Page
     
        Protected Sub Wizard1_FinishButtonClick(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.WizardNavigationEventArg  s) Handles Wizard1.FinishButtonClick
            Dim body As String
            body = txtComments.Text & ControlChars.CrLf & txtStreet.Text & ControlChars.CrLf & txtCity.Text
            SendMail(txtEmail.Text, body)
        End Sub
     
        Private Sub SendMail(ByVal from As String, ByVal body As String)
            Dim mailServerName As String =
            Dim message As MailMessage = New MailMessage(from, "a@ra.com", "feedback", body)
            Dim mailClient As SmtpClient = New SmtpClient
     
            mailClient.Host = mailServerName
            mailClient.Send(message)
            message.Dispose()
        End Sub

    Comment

    • cluce
      New Member
      • Sep 2007
      • 29

      #3
      great. thanx a million

      Comment

      • Killer42
        Recognized Expert Expert
        • Oct 2006
        • 8429

        #4
        Originally posted by cluce
        ...(from, "a@ra.com", "feedback", body)
        I just wanted to check, is that a real e-mail address? If so, I'll blank it out. Scammers and spammers regularly scan forums such as this looking for victims, and we don't like to help them.

        Comment

        Working...