title image


Smiley Ich überwache 4 Verzeichnisse und bekomme immer 3 Mails...???
Hallo "dev",



ich überwache mit meinem Prog 4 Verzeichnisse auf einem EMailserver. Als erstes wir ein Ping gesendet und ein Kreis ist entweder grün oder rot. Danach zählt das Prog die Dateien in 4 Verzeichnissen und ändert hier einen Farbbalken zwischen grün, oramge und rot (je nach Anzahl Dateien).

Mein Problem ist aber, dass ich immer 3 Mails zugestellt bekomme, statt nur einer und ich als Anfänger verstehe nocht nicht warum.

Könntest du mal über meinen Beispielcode schauen und mir vielleicht den Fehler sagen?

Ich komme einfach nicht darauf. Vielen Dank für jede Unterstützung!!!



Gruß Horst







Imports System.Net

Imports System

Imports System.runtime.InteropServices

Imports System.Web

Imports System.net.mail

Imports System.Net.Sockets





Public Class Form1





Private Sub Form1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles MyBase.Paint



start:

'************ CHECK EHS5 ***************************************************************************************

Dim ergebnis As Boolean

Dim options As New System.Net.NetworkInformation.PingOptions(5, True)

Dim pinger As New System.Net.NetworkInformation.Ping

Dim reply As System.Net.NetworkInformation.PingReply = pinger.Send("172.16.166.57", 500)



'****************EHS5 PING ********************************************************************************************



Dim reply5 As System.Net.NetworkInformation.PingReply = pinger.Send("172.16.166.57", 500)

TextBox16.Text = ("Status= " + reply5.Status.ToString() + ", response time= " & reply5.RoundtripTime.ToString())



Try

ergebnis = My.Computer.Network.Ping("172.16.166.57")

Catch ex As Exception

TextBox16.Text = ("Exception")

Exit Sub

End Try



If ergebnis Then

TextBox12.Text = ("NetworkPing ist ok!")



Dim pen As New Pen(Color.Green, 40)

Dim font As New Font("arial", 10, FontStyle.Bold)



e.Graphics.SmoothingMode = Drawing.Drawing2D.SmoothingMode.AntiAlias

e.Graphics.TextRenderingHint = Drawing.Text.TextRenderingHint.ClearTypeGridFit

'1.te Zahl = links/rechts, 2.te = oben/unten, 3.te + 4.te = Größe des Kreises/Ellipse

e.Graphics.DrawEllipse(pen, 490, 285, 40, 40)

Else

TextBox12.Text = ("Timeout!")



Dim pen As New Pen(Color.Red, 40)

Dim font As New Font("arial", 10, FontStyle.Bold)



e.Graphics.SmoothingMode = Drawing.Drawing2D.SmoothingMode.AntiAlias

e.Graphics.TextRenderingHint = Drawing.Text.TextRenderingHint.ClearTypeGridFit

'1.te Zahl = links/rechts, 2.te = oben/unten, 3.te + 4.te = Größe des Kreises/Ellipse

e.Graphics.DrawEllipse(pen, 490, 285, 40, 40)

End If





'****** Verzeichnisse festlegen auf dem EHS5 ****************************************************************



'******* Verzeichnisse EHS5 prüfen **************************************************************************



Dim checkdir5 As New System.IO.DirectoryInfo("p:\inbound")

Dim fi5 As System.IO.FileInfo() = checkdir5.GetFiles()

TextBox18.Text = ("" & checkdir5.GetFiles.Length.ToString() & "")



If checkdir5.GetFiles.Length.ToString() < 50 Then

Dim GraphicsFun As System.Drawing.Graphics

GraphicsFun = Me.CreateGraphics

Dim brushcolor As New SolidBrush(Color.Green)

GraphicsFun.FillRectangle(brushcolor, 471, 364, 80, 20)

End If



If checkdir5.GetFiles.Length.ToString() > 50 And checkdir5.GetFiles.Length.ToString() < 100 Then

Dim GraphicsFun As System.Drawing.Graphics

GraphicsFun = Me.CreateGraphics

Dim brushcolor As New SolidBrush(Color.Orange)

GraphicsFun.FillRectangle(brushcolor, 471, 364, 80, 20)

End If



If checkdir5.GetFiles.Length.ToString() > 100 Then

Dim GraphicsFun As System.Drawing.Graphics

GraphicsFun = Me.CreateGraphics

Dim brushcolor As New SolidBrush(Color.Red)

GraphicsFun.FillRectangle(brushcolor, 471, 364, 80, 20)



Try

Dim sc1 As New SmtpClient("172.16.101.40")

Dim msg1 As New MailMessage

Dim addr1 As New MailAddress("Genesys.Eye@domain.de")

msg1.From = addr1

msg1.To.Add("onkel.hotte@domain.de")

msg1.Subject = "Warnung - Genesys Mailsystem!"

msg1.Priority = MailPriority.High

msg1.Body = "Über 100 Dateien im Verzeichnis: EHS5\mail\inbound!"

sc1.Send(msg1)

Catch ex As SmtpException

MessageBox.Show("SMTP Fehler : " & ex.Message)

End Try





End If



'***********************************************************************************

Dim checkdir6 As New System.IO.DirectoryInfo("p:\inbound\bad")

Dim fi6 As System.IO.FileInfo() = checkdir6.GetFiles()

TextBox17.Text = ("" & checkdir6.GetFiles.Length.ToString() & "")



If checkdir6.GetFiles.Length.ToString() <= 2 Then

Dim GraphicsFun As System.Drawing.Graphics

GraphicsFun = Me.CreateGraphics

Dim brushcolor As New SolidBrush(Color.Green)

GraphicsFun.FillRectangle(brushcolor, 471, 390, 80, 20)

End If



If checkdir6.GetFiles.Length.ToString() > 2 And checkdir6.GetFiles.Length.ToString() <= 8 Then

Dim GraphicsFun As System.Drawing.Graphics

GraphicsFun = Me.CreateGraphics

Dim brushcolor As New SolidBrush(Color.Orange)

GraphicsFun.FillRectangle(brushcolor, 471, 390, 80, 20)



End If



If checkdir6.GetFiles.Length.ToString() > 8 Then

Dim GraphicsFun As System.Drawing.Graphics

GraphicsFun = Me.CreateGraphics

Dim brushcolor As New SolidBrush(Color.Red)

GraphicsFun.FillRectangle(brushcolor, 471, 390, 80, 20)



'Warnung mit EMail und SMS versenden:

Try

Dim sc2 As New SmtpClient("172.16.101.40")

Dim msg2 As New MailMessage

Dim addr2 As New MailAddress("Genesys.Eye@domain.de")

msg2.From = addr2

msg2.To.Add("onkel.hotte@domain.de")

msg2.Subject = "Warnung - Genesys Mailsystem!"

msg2.Priority = MailPriority.High

msg2.Body = "Über 20 Dateien im Verzeichnis: EHS5\mail\inbound\bad!"

sc2.Send(msg2)

Catch ex As SmtpException

MessageBox.Show("SMTP Fehler : " & ex.Message)

End Try

End If



'***********************************************************************************



Dim checkdir7 As New System.IO.DirectoryInfo("p:\outbound")

Dim fi7 As System.IO.FileInfo() = checkdir7.GetFiles()

TextBox15.Text = ("" & checkdir7.GetFiles.Length.ToString() & "")



If checkdir7.GetFiles.Length.ToString() < 50 Then

Dim GraphicsFun As System.Drawing.Graphics

GraphicsFun = Me.CreateGraphics

Dim brushcolor As New SolidBrush(Color.Green)

GraphicsFun.FillRectangle(brushcolor, 471, 416, 80, 20)

End If



If checkdir7.GetFiles.Length.ToString() > 50 And checkdir7.GetFiles.Length.ToString() < 100 Then

Dim GraphicsFun As System.Drawing.Graphics

GraphicsFun = Me.CreateGraphics

Dim brushcolor As New SolidBrush(Color.Orange)

GraphicsFun.FillRectangle(brushcolor, 471, 416, 80, 20)

End If



If checkdir7.GetFiles.Length.ToString() > 100 Then

Dim GraphicsFun As System.Drawing.Graphics

GraphicsFun = Me.CreateGraphics

Dim brushcolor As New SolidBrush(Color.Red)

GraphicsFun.FillRectangle(brushcolor, 471, 416, 80, 20)



Try

Dim sc3 As New SmtpClient("172.16.101.40")

Dim msg3 As New MailMessage

Dim addr3 As New MailAddress("Genesys.Eye@domain.de")

msg3.From = addr3

msg3.To.Add("onkel.hotte@domain.de")

msg3.Subject = "Warnung - Genesys Mailsystem!"

msg3.Priority = MailPriority.High

msg3.Body = "Über 100 Dateien im Verzeichnis: EHS5\mail\outbound!"

sc3.Send(msg3)

Catch ex As SmtpException

MessageBox.Show("SMTP Fehler : " & ex.Message)

End Try

End If



'***********************************************************************************



Dim checkdir8 As New System.IO.DirectoryInfo("p:\outbound\bad")

Dim fi8 As System.IO.FileInfo() = checkdir8.GetFiles()

TextBox13.Text = ("" & checkdir8.GetFiles.Length.ToString() & "")





If checkdir8.GetFiles.Length.ToString() < 10 Then

Dim GraphicsFun As System.Drawing.Graphics

GraphicsFun = Me.CreateGraphics

Dim brushcolor As New SolidBrush(Color.Green)

GraphicsFun.FillRectangle(brushcolor, 471, 442, 80, 20)

End If



If checkdir8.GetFiles.Length.ToString() > 10 And checkdir8.GetFiles.Length.ToString() < 20 Then

Dim GraphicsFun As System.Drawing.Graphics

GraphicsFun = Me.CreateGraphics

Dim brushcolor As New SolidBrush(Color.Orange)

GraphicsFun.FillRectangle(brushcolor, 471, 442, 80, 20)

End If



If checkdir8.GetFiles.Length.ToString() > 20 Then

Dim GraphicsFun As System.Drawing.Graphics

GraphicsFun = Me.CreateGraphics

Dim brushcolor As New SolidBrush(Color.Red)

GraphicsFun.FillRectangle(brushcolor, 471, 442, 80, 20)



'Warnung mit EMail und SMS versenden:

Try

Dim sc4 As New SmtpClient("172.16.101.40")

Dim msg4 As New MailMessage

Dim addr4 As New MailAddress("Genesys.Eye@domain.de")

msg4.From = addr4

msg4.To.Add("onkel.hotte@domain.de")

msg4.Subject = "Warnung - Genesys Mailsystem!"

msg4.Priority = MailPriority.High

msg4.Body = "Über 20 Dateien im Verzeichnis: EHS5\mail\outbound\bad!"

sc4.Send(msg4)

Catch ex As SmtpException

MessageBox.Show("SMTP Fehler : " & ex.Message)

End Try

End If



End Sub



Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick

Timer1.Start()

Timer1.Interval = 300000

Application.Restart()

End Sub

End Class

geschrieben von

Login

E-Mail:
  

Passwort:
  

Beitrag anfügen

Symbol:
 
 
 
 
 
 
 
 
 
 
 
 
 

Überschrift: