Dim Mail As New MailMessage
    Mail.Subject = ""
    Mail.To.Add("")
    Mail.From = New MailAddress("")
    Mail.Body = textbox1.text

    " How i can add 5 textboxes in body "


    Dim SMTP1 As New SmtpClient("smtp-mail.outlook.com")
    SMTP1.EnableSsl = True
    SMTP1.Credentials = New System.Net.NetworkCredential("mail@mail.com", "password")
    SMTP1.Port = "587"
    SMTP1.Send(Mail)

How i can add 5 textboxes in body

Recommended Answers

All 2 Replies

Hi

You could do simple string concatenation:

Dim bodyString As String = TextBox1.Text & TextBox2.Text & TextBox3.Text .....

And then using Mail.Body = bodyString

Or use a StringBuilder if you are going to be concatenating a large number of strings:

    Dim sb As New StringBuilder
    sb.Append(TextBox1.Text)
    sb.Append(TextBox2.Text)
    ....

And then use Mail.Body = sb.ToString

Also, note that both of these do not place a carriage return between each one so if you need this then in the first example you could use:

    Dim bodyString As String = TextBox1.Text & Environment.NewLine & TextBox2.Text...

Or in the case of the StringBuilder use the AppendLine method.

HTH

thanks worked

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.