Resolved Email textbox inputs

KRP

Member
Joined
Jan 9, 2010
Messages
9
Programming Experience
Beginner
Could anyone point me in the right direction to solve this. I have three different textboxes on my form. What I am trying to do is send the inputs the user puts into the text boxes in an email. I have the email working but all the text is run together. I would like to have the inputs from the different textboxes to be on seperate lines.

Here is the code I have. Thanks for any help.

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim mymailmsg As New MailMessage

Try
mymailmsg.From = New MailAddress("gdy3eg3oyge@gmail.com")
mymailmsg.To.Add("jhdiwueho2@aol.com")
mymailmsg.Subject = "Waste Report"
mymailmsg.Body = TextBox1.Text + TextBox2.Text + Textbox3.Text<------------here is my problem but I don't know how to fix
Dim smtp As New SmtpClient("smtp.gmail.com")
smtp.Port = 587
smtp.EnableSsl = True
smtp.Credentials = New System.Net.NetworkCredential("jewhdepiuh@gmail.com", "kjoqwijs")
smtp.Send(mymailmsg)
MsgBox("Sent")

Catch ex As Exception

End Try

End Sub
 
Last edited:
Hi!

Try this
mymailmsg.Body = "First textbox: " & TextBox1.Text & "<br/>" & "Second textbox: " & TextBox2.Text & "<br/>" & "Third textbox: " & Textbox3.Text
 
Hi!

Try this
mymailmsg.Body = "First textbox: " & TextBox1.Text & "<br/>" & "Second textbox: " & TextBox2.Text & "<br/>" & "Third textbox: " & Textbox3.Text

Don't know if I done this right or not as I am new to programming but I couldn't get this to work.

Thanks for any help.
 
KRP said:
Don't know if I done this right or not as I am new to programming but I couldn't get this to work.
MailMessage.IsBodyHtml Property (System.Net.Mail)

If you're not using Html body content you can insert regular string linefeeds like this:
VB.NET:
mymailmsg.Body = TextBox1.Text & vbNewLine & TextBox2.Text
 
Thanks JohnH. I don't know if this code is sound as I'm a newbe but I got it to work with this.




Dim mymailmsg As New MailMessage
Dim a As String = TextBox5.Text
Dim b As String = TextBox1.Text
Dim c As String = TextBox2.Text
Dim d As String = TextBox3.Text
Dim f As String = TextBox4.Text
Dim g As String = TextBox6.Text


Try

mymailmsg.From = New MailAddress(xxxx@gmail.com")
mymailmsg.To.Add(xxx@aol.com")
mymailmsg.Subject = "Waste Report"
mymailmsg.Body = a & vbCrLf & b & vbCrLf & c & vbCrLf & d & vbCrLf & f & vbCrLf & g

Dim smtp As New SmtpClient("smtp.gmail.com")
smtp.Port = 587
smtp.EnableSsl = True
smtp.Credentials = New System.Net.NetworkCredential("xxxx@gmail.com", "password")
smtp.Send(mymailmsg)
MsgBox("Sent")

Catch ex As Exception

End Try
 

Latest posts

Back
Top