Dear All
You can create your own keep alive service by blow code (Note i got this code but it still not tested yet)
original post
http://al-atari.net/?p=569
Imports System.IO
Imports System.Net
Imports System.Text
Imports System.Net.Mail
Module Startup
Sub Main()
Call CheckOneSite("http://www.part-time-work-at-home-opportunities.com/keepalive.aspx")
Call CheckOneSite("http://www.site2.com")
Call CheckOneSite("http://www.site3.com")
Call CheckOneSite("http://www.siten.com")
End Sub
Private Sub CheckOneSite(ByVal pUrl As String)
Try
' Create a request for the URL.
Dim lRequest As WebRequest = WebRequest.Create(pUrl)
' If required by the server, set the credentials.
lRequest.Credentials = CredentialCache.DefaultCredentials
' Get the response.
Dim lResponse As HttpWebResponse = _
CType(lRequest.GetResponse(), HttpWebResponse)
'Check the response code
If lResponse.StatusCode <> HttpStatusCode.OK Then
Dim lSb As New StringBuilder
lSb.AppendFormat("Received an invalid Http response code: {0}", _
lResponse.StatusCode.ToString)
Call SendNotification(pUrl, lSb.ToString)
End If
lResponse.Close()
Console.WriteLine(Now.ToString & " - Site Check Ok: " & pUrl)
Catch ex As Exception
Call SendNotification(pUrl, ex.Message)
End Try
End Sub
Private Sub SendNotification(ByVal pUrl As String, ByVal pMessage As String)
'Start by creating a mail message object
Dim MyMailMessage As New MailMessage()
'From requires an instance of the MailAddress type
MyMailMessage.From = New MailAddress("<email>@gmail.com")
'To is a collection of MailAddress types
MyMailMessage.To.Add("<email>@gmail.com")
MyMailMessage.Subject = String.Format("SiteChecker error: {0}", pUrl)
MyMailMessage.Body = pMessage
'Create the SMTPClient object and specify the SMTP GMail server
Dim SMTPServer As New SmtpClient("smtp.gmail.com")
SMTPServer.Port = 587
SMTPServer.Credentials = New _
System.Net.NetworkCredential("<email>@gmail.com", "<password>")
SMTPServer.EnableSsl = True
Try
SMTPServer.Send(MyMailMessage)
Catch ex As SmtpException
Console.WriteLine(ex.Message)
End Try
End Sub
End Module
Regard
Rashid Imran Bilgrami
Excеllent post. I will Ьe facing many of tҺese іssues ɑs well..
ReplyDelete