If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ASP > Cdonts Email Test System

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 04-21-06, 06:19
donaldt donaldt is offline
Registered User
 
Join Date: Jan 2002
Location: Nottingham - UK
Posts: 113
Wink Cdonts Email Test System

Hi Folks - im wondering if its posssible to have a CDONTS email sent evey 30 mins for example sent as a test automatically just letting me know the email facility is happy and well?

Im using MS WIndows 2003 Standard, IIS 6 etc.

Thanks in advance

Donald
Reply With Quote
  #2 (permalink)  
Old 04-21-06, 10:35
csamuels csamuels is offline
Registered User
 
Join Date: Mar 2006
Location: south jersey, usa
Posts: 53
you can either write a asp script to send the email and force the client to refresh the page every 30 mins or write a vbscript to send the email and setup a schedules task to run the script every thirty minutes.


here's a email script i use at work to notify me when a scheduled server reboot occurs

Code:
<% Option Explicit %>

<% 
dim conn, rs, routefile, mname, mfunct, mip, query

routefile = "\\sus\tasks\restartsched\servers.mdb"

sub openconn ' open a connection to access db'
  dim tries
  set conn = CreateObject("ADODB.Connection") 'prep connection'
  set rs = CreateObject("ADODB.Recordset") ' prep recordset'

  tries = 0 ' clear tries counter'
  do 'try to open connection to the db
    conn.open "DRIVER={Microsoft Access Driver (*.mdb)};" &_ 
              "DBQ=" & RouteFile & ";DefaultDir=;UID=;PWD=;"
    tries = tries + 1
    if (err.number <> 0) then 'if errored, close this connection
      conn.close
    end if
  Loop While (Err.Number<>0) And tries < 10 'if errored, try again. MAX TRIES = 10
end sub

sub closeconn ' close the connection to the db
  rs.close
  set rs = nothing
  conn.close
  set conn = nothing
end sub

sub main
openconn
response.write request.servervariables("REMOTE_ADDR") & "<br>"
mip = trim(request.servervariables("REMOTE_ADDR"))
query = "Select ipaddress, machinename, function from irschedl where ipaddress = '" &_
        mip & "'"
rs.open query, conn

if err.number<>0 then 
  response.write "An error has occurred while trying to execute a query - " & query & "<BR>" & Err.description
else
  if rs.eof then
    mname = "Machine Name Not Found In DB"
  else
    response.write rs.fields("ipaddress") & " - " & mip & "<BR>"
    mname = rs.fields("machinename")
    mfunct = rs.fields("function")
  end if
      
       Dim MyEmail

       Set MyEmail = Server.CreateObject("CDONTS.NewMail")

       MyEmail.From = "cxxxxx@fxxxxxxem.com"

       MyEmail.To = "cxxxxs@fxxxxxem.com; wxxxx@fxxxxxm.com"
       'MyEmail.To = "cxxxxs@xxxx"

       MyEmail.Subject = mname & " Restarted"
 
       MyEmail.Body = mname & " was restarted successfully. The database for server names & ips is located at " &_
                      routefile & " This machine runs " & mfunct
                      
       MyEmail.Send

       Set MyEmail = Nothing 
       
       response.write "email sent"
  
end if
closeconn
end sub 'end main       
main
%>
<script type="text/javascript">
window.close()
</script>
<p><input type="button" onclick="window.close()" value="Close Window"></p>
__________________
"They say Moses split the Red Sea
I split the blunt and rolled the fat one, I'm deadly"
-- Tupac 'Blasphemy'
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On