Results 1 to 2 of 2
  1. #1
    Join Date
    Jan 2002
    Location
    Nottingham - UK
    Posts
    113

    Wink Unanswered: 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

  2. #2
    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'

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •