Support Forums
Add Multiple textbox values to email? - Printable Version

+- Support Forums (https://www.supportforums.net)
+-- Forum: Categories (https://www.supportforums.net/forumdisplay.php?fid=87)
+--- Forum: Coding Support Forums (https://www.supportforums.net/forumdisplay.php?fid=18)
+---- Forum: Visual Basic and the .NET Framework (https://www.supportforums.net/forumdisplay.php?fid=19)
+---- Thread: Add Multiple textbox values to email? (/showthread.php?tid=5096)



Add Multiple textbox values to email? - Extasey - 02-28-2010

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?


RE: Add Multiple textbox values to email? - Extasey - 02-28-2010

No one at all?


RE: Add Multiple textbox values to email? - loltest - 02-28-2010

Use & to concatenate strings.

Eg.

Code:
Mail.Body = txtName.Text & Environment.Newline & txtBody.Text



RE: Add Multiple textbox values to email? - Extasey - 03-01-2010

Ahh, thanks. I'll give it a try.
Beautiful. Thanks mate.