Script to send Emails

Home Forums Scripting General Scripting Script to send Emails

Viewing 1 post (of 1 total)
  • Author
    Posts
  • Avatar
    Retaliator
    Member
    #127548

    Hi Guys,

    I need a script to send email from my computer, while pinging a server and if there is NO ping (time out) it will send me email and 2nd option pager.
    I am using this script on my servers ou via GPO, but i want the email to be sent from MY computer not from the server.

    Set objNetwork = CreateObject(“Wscript.Network”)
    strComputer = objNetwork.ComputerName
    Set objEmail = CreateObject(“CDO.Message”)
    objEmail.From = strComputer & “@ENTERYOUR DOMAIN HERE(i.e. XYZ.com)”
    objEmail.To = “ENTER RECIPIENT EMAIL ADDRESS HERE”
    objEmail.Subject = “Reboot Requested”
    objEmail.Textbody = “An admin has requested a reboot of ” & strComputer & “. Please ignore alerts, unless they last more than 15 minutes.”
    objEmail.Configuration.Fields.Item (“http://schemas.microsoft.com/cdo/configuration/sendusing”) = 2
    objEmail.Configuration.Fields.Item (“http://schemas.microsoft.com/cdo/configuration/smtpserver”) = “ENTER MAIL SERVER NAME HERE”
    objEmail.Configuration.Fields.Item (“http://schemas.microsoft.com/cdo/configuration/smtpserverport”) = 25
    objEmail.Configuration.Fields.Update
    objEmail.Send[/CODE]

    Thanks, Retaliator[CODE]Set objNetwork = CreateObject(“Wscript.Network”)
    strComputer = objNetwork.ComputerName
    Set objEmail = CreateObject(“CDO.Message”)
    objEmail.From = strComputer & “@ENTERYOUR DOMAIN HERE(i.e. XYZ.com)”
    objEmail.To = “ENTER RECIPIENT EMAIL ADDRESS HERE”
    objEmail.Subject = “Reboot Requested”
    objEmail.Textbody = “An admin has requested a reboot of ” & strComputer & “. Please ignore alerts, unless they last more than 15 minutes.”
    objEmail.Configuration.Fields.Item (“http://schemas.microsoft.com/cdo/configuration/sendusing”) = 2
    objEmail.Configuration.Fields.Item (“http://schemas.microsoft.com/cdo/configuration/smtpserver”) = “ENTER MAIL SERVER NAME HERE”
    objEmail.Configuration.Fields.Item (“http://schemas.microsoft.com/cdo/configuration/smtpserverport”) = 25
    objEmail.Configuration.Fields.Update
    objEmail.Send[/CODE]

    Thanks, Retaliator

Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.