Dim Mail As New MailMessage
    Mail.Subject = ""
    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"

How i can add 5 textboxes in body


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

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.


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.