Support Forums

Full Version: Add Multiple textbox values to email?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I haven't coded in ages and am only just getting back into it.
I thought I would just much around with a few functions that everyone seems to use in their programs as a bit of a slow start back into it. I seem to be doing pretty well so far, especially seeing as vb.net is a bit different for me (learnt on vb6).
Anyway, I was messing with the e-mail function... and I could only add one textbox value to the body. Here is the code I'm trying to use:
Code:
Dim Mail As New MailMessage
        Mail.Subject = txtUser.Text
        Mail.To.Add(txtGMAILUser.Text)
        Mail.From = New MailAddress(txtGMAILUser.Text)
        Mail.Body = txtName.Text
        Dim SMTP As New SmtpClient("smtp.gmail.com")
        SMTP.EnableSsl = True
        SMTP.Credentials = New System.Net.NetworkCredential(txtGMAILUser.Text, txtGMAILPass.Text)
        SMTP.Port = 587
        SMTP.Send(Mail)

I want to add more text boxes on Mail.body, but can't figure out how to do it. I just keep creating syntax errors.
Does anyone know how to do this?
No one at all?
Use & to concatenate strings.

Eg.

Code:
Mail.Body = txtName.Text & Environment.Newline & txtBody.Text
Ahh, thanks. I'll give it a try.
Beautiful. Thanks mate.