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.


Edited 1 Year Ago by djjeavons

This question has already been answered. Start a new discussion instead.