banging my head! Please HELP ME

NEWBIE at this!!!The Value_Update comman grabs data out of a
Programmable Logic Controller that monitors our tank levels, pH's, on/off of
motors/pumps. What I am trying to accomplish is when the value is either on
or off, >90 or <90 etc... is to send an email out to notify me and other
managers/superintendents that a critical value has been reached. Once that
email has been sent what I would like to do is to delay another email from
going out for 15min or longer so that the operator has time to fix the issues
and after x amount of time checks the value again if it is not fixed the code
runs again and another email is sent out until the issue is resolved
respectively. (24/7 operation). The value that it is looking at is real time
data updated in ms. Any suggestions on how I can accomplish this? the code works but will send email out constantly. So say it takes 10 minutes to get the level >90 then we would have 10 or more emails. There would not be anyone at the system to click any buttons etc... it must run by itself with no user interaction.

Private Sub Value_DataUpdate()

Dim retstatus As Long
Dim vTime As Variant
If Value.GetValue(vTime, retstatus) < 90 Then

Dim objOutlook As Outlook.Application
Dim objOutlookMsg As Outlook.MailItem
Dim theNamespace As Outlook.Namespace
Dim myRecipient As Outlook.Recipient

Set objOutlook = New Outlook.Application

Set theNamespace = objOutlook.GetNamespace("MAPI")
Set objOutlookMsg = objOutlook.CreateItem(olMailItem)

objOutlookMsg.To = "xxxxxx@whatever.com"
objOutlookMsg.Subject = "We have a critical operations alarm!!!
objOutlookMsg.Body = "URGENT SYSTEM ALARM!!!!!!!!!"
objOutlookMsg.Importance = olImportanceHigh

objOutlookMsg.Send

Set myRecipient = Nothing
Set objOutlookMsg = Nothing
'theNamespace.SyncObjects.Item(1).Start

Set theNamespace = Nothing
Set objOutlook = Nothing

End If

End Sub
[2075 byte] By [randy2008] at [2007-11-20 10:18:42]
# 1 Re: banging my head! Please HELP ME
You would have to create a trusted service, and then make it unique for each machine. Ever since SP2, you can't send emails thru outlook without user intervention and a delay. thank spammers past...
dglienna at 2007-11-9 19:35:13 >
# 2 Re: banging my head! Please HELP ME
it is only run on 1 machine and I have a work around for that, but if you can help with the problem I would be appreciate it very muc...
randy2008 at 2007-11-9 19:36:19 >
# 3 Re: banging my head! Please HELP ME
You could use a Timer, and count 60 seconds before firing off a letter.
Add a flag, and you can stop it at will.
dglienna at 2007-11-9 19:37:18 >
# 4 Re: banging my head! Please HELP ME
I am new at this not familiar w/ timers, how would that code look like and where would i place it in my existing on?
randy2008 at 2007-11-9 19:38:23 >
# 5 Re: banging my head! Please HELP ME
This counts up: h:m:s format in the caption of the form.
Counts 6 minutes.

Option Explicit
' Add a Timer control to your project. It will be Timer1
' It looks like a stop watch in the IDE.
Dim OldTime As Date
Dim newTime As Date
Dim diff As Date

Private Sub Form_Load()
OldTime = Time
Timer1.Interval = 1000 ' 1 second
Timer1.Enabled = True
End Sub

Private Sub Timer1_Timer()
Static x As Long
Static zz$, ss$
x = x + 1
newTime = Time
diff = DateDiff("s", OldTime, newTime)
Form1.Caption = (diff \ 3600) & ":" & Format((diff \ 60 Mod 60), "00") & ":" & _
Format((diff - ((diff \ 60) * 60)), "00")
' Debug.Print (diff \ 3600) & ":" & Format((diff \ 60 Mod 60), "00") & ":" & _
Format((diff - ((diff \ 60) * 60)), "00")
If newTime = DateAdd("s", 360, OldTime) Then ' Add 360 seconds
Timer1.Enabled = False
' You time is UP! Do something!
Beep
End If
End Sub
dglienna at 2007-11-9 19:39:17 >
# 6 Re: banging my head! Please HELP ME
thanks!!!!! So someone will have to manually be there when this timers ends? If that is the case then there will be no one there to so anything... and how would you set in the code for say 30 minutes?
randy2008 at 2007-11-9 19:40:22 >
# 7 Re: banging my head! Please HELP ME
See this part?

If newTime = DateAdd("s", 360, OldTime) Then ' Add 360 seconds
Timer1.Enabled = False ' this stops the timer
' You time is UP! Do something!
Beep
' so you can now do what you want to do.
End If

after 6 minutes (6 x 60 seconds) it beeps and stops.

30x60=1800 seconds.

Could also use this:

If newTime = DateAdd("n", 30, OldTime) Then
dglienna at 2007-11-9 19:41:26 >