email sending problem

joshuadeboer

Well-known member
Joined
May 28, 2008
Messages
45
Location
Hillsboro, OR
Programming Experience
1-3
Hi, i'm making a network monitoring program, and the way it works is after five ping-fails, it sends an email, but i cant get it to work! the test email works fine, so its not the email code.


VB.NET:
Dim s As Short
        Dim newstr(4) As String
        Dim I As Integer
        Dim name As String
        Dim MS As String
        Dim Errors As String
        Dim IP As String
        Dim errorState As String
        Dim ItemCount As Integer
        Dim Count As Integer
        ItemCount = lstMain.Items.Count
        For I = 0 To ItemCount - 1
            For s = 0 To 4
                newstr(s) = listview1.Items.Item(I).SubItems(s).Text
            Next
            Count = listview1.Items.Item(I).Index
            name = newstr(0)
            IP = newstr(3)
            If DoPing(IP) = True Then
                newstr(1) = (GetRep(IP))
                If newstr(4) = 6 Then
                    SendEmail()
                    newstr(4) = 1
                Else
                    newstr(4) = 1
                End If
                name = newstr(0)
                IP = newstr(3)
                MS = newstr(1)
                Errors = newstr(2)
                errorState = newstr(4)
                listview1.Items.RemoveAt(Count)
                Dim Ping As New ListViewItem
                Ping.Name = name
                Ping.Text = name
                Ping.BackColor = Color.WhiteSmoke
                Ping.SubItems.Add(MS)
                Ping.SubItems.Add(Errors)
                Ping.SubItems.Add(IP)
                Ping.SubItems.Add(errorState)
                listview1.Items.Insert(Count, Ping)
                listview1.Refresh()
            Else
                newstr(2) = newstr(2) + 1
                newstr(1) = "<error>"
                If newstr(4) = 5 Then
                    SendEmail()
                    newstr(4) = newstr(4) + 1
                Else
                    If Not newstr(4) = 6 Then
                        newstr(4) = newstr(4) + 1
                    End If
                End If
                name = newstr(0)
                IP = newstr(3)
                MS = newstr(1)
                Errors = newstr(2)
                errorState = newstr(4)
                Dim Ping As New ListViewItem
                listview1.Items.RemoveAt(Count)
                Ping.Name = name
                Ping.Text = name
                Ping.BackColor = Color.Red
                Ping.SubItems.Add(MS)
                Ping.SubItems.Add(Errors)
                Ping.SubItems.Add(IP)
                Ping.SubItems.Add(errorState)
                listview1.Items.Insert(Count, Ping)
                listview1.Refresh()
            End If
        Next

I there something i'm doing wrong :confused:
 
I just love posts that say "This is broken. What's wrong with this" and dump a load of code (that doesnt obey .NET naming conventions) in.
 
Cjard requested information on what line it errored out on and what the error message is. Until this information is supplied you'll be hard pressed to get additional help on the subject.
 
Is there something I'm doing wrong??? :confused:

Yes. Youre not responding to my implication that you need to add more detail to your post, like where the error occurrs and what the error is. We're all busy people. We don't have time to read 200 lines of your (bad*) code "just because there might be some error in it somewhere".

Your lack of effort is 100% the root cause of my lack of interest in reading your post and helping you out


*because it's full of magic numbers ergo it is not self documenting and no comments are present
 
In addition to everything Cjard and MattP have said, the following fact confuses me. Your post is entitled "email sending problem", yet your first sentence says:-

the test email works fine, so its not the email code.

So is it an e-mail sending problem or not?

Please dont think that we are deliberately all out to "have a dig" at you (even though it may seem like it :D). It's just that if you would like us to reply, the best way is to provide as much information as possible at the outset. Besides, I have far better things to do than try and wade through 'difficult' posts - and as Cjard said, we're all busy people. We genuinely want to help, but please help us to help you :)
 
Sorry, i didn't quite understand, as to what line it errors on, i don't know, because it doesn't really error, it just won't work! It does the background color fine, but it won't send the email!

Sorry again :(
 
Does it ever hit your SendEmail() call?

Have you tried adding a breakpoint and stepping through the code to see what is actually happening?

What's populated in newstr(4) when you're checking it?
 
No, it doesn't hit the send email call. because i know it works, i will try adding breakpoints. newstr(4) is the count that tell's the program to send the email, it keeps track of how many fails IN A ROW failed, so when it reaches 5, it's suppost to send the email.
 
I played with it more, and discovered that whenever i run it on a 64x computer, it won't send the email, but does everything else fine. There might be somthing blocking the email, but i don't think so because the test email (a button) works fine.
 
I played with it more, and discovered that whenever i run it on a 64x computer, it won't send the email, but does everything else fine. There might be somthing blocking the email, but i don't think so because the test email (a button) works fine.

No, it doesn't hit the send email call.

I would say from your post here that it doesn't have anything to do w/ email at all. It's kind of hard to send an email from your program if that call doesn't get made.
 
Back
Top