Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Time Out email sending.

Status
Not open for further replies.

Work23

Technical User
Mar 8, 2005
94
US
Hello. I have a script that monitors a website and sends an email if the site is down. My issue is, I want to just receive one email in the span of the 10 minutes the program is ran. So, essentially, the program is run every 10 minutes. Should the specified error occur, an email is sent. My problem now is, if the error is existent after the 10 minutes, I get another email. I would just need one notification. How would I set this up programmatically? Thanks so much. Take care. My code for the SMTP is below:

if (myTitle[1] != "Login" || StatusResponse != "OK")
{
InfoMessage("Page could not load, an email is being sent to the webmaster")
Smtp.To="<somebody@somebody.com>";
Smtp.From= "host@somebody.com";
Smtp.Subject="Your Site is down!!";
Smtp.Message="Urgent! Urgent! Your Site is Down Smtp.Send();
InfoMessage(Smtp.GetStatusLine());

}
 
Something like this should work:

Code:
[b]var emailedFlag = false;[/b]
if (myTitle[1] != "Login" || StatusResponse != "OK") {
	[b]if (!emailedFlag)
		emailedFlag = true;[/b]
		InfoMessage("Page could not load, an email is being sent to the webmaster");
		Smtp.To="<somebody@somebody.com>";
		Smtp.From= "host@somebody.com";
		Smtp.Subject="Your Site is down!!";
		Smtp.Message="Urgent! Urgent! Your Site is Down";
		Smtp.Send();
		InfoMessage(Smtp.GetStatusLine());
	}
} [b]else {
	emailedFlag = false;
}[/b]

Hope this helps,
Dan

[tt]D'ya think I got where I am today because I dress like Peter Pan here?[/tt]
[banghead]

 
I'm sorry, I"m just a bit confused. So when the program runs the second time, what tells it that the first email was already sent, and it should not send again? Thanks so much.
 

The bits I put in bold do that.

Dan


[tt]D'ya think I got where I am today because I dress like Peter Pan here?[/tt]
[banghead]

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top