0
 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

2
Contributors
2
Replies
10
Views
2 Years
Discussion Span
Last Post by OMER AHMED
0

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

Edited by djjeavons

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.