troubleshooting Question

Is there a way to send an email as high priority on a single condition?

Avatar of WeberTech
WeberTechFlag for United States of America asked on
VB ScriptMicrosoft Server Apps
10 Comments1 Solution560 ViewsLast Modified:
I was wondering if there was a way to send an email as priority if a certain condition is met?  Here is my code that I have so far but I don't know how to add the high priority code to it?  I want it to only send the email as high priority if the job failed.  Can someone help me?

Set objFSO = CreateObject("Scripting.FileSystemObject")

strFileName = "Path to Log"
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile(strFileName, 1, False)
strText = objFile.ReadAll
objFile.Close

'If Instr(strText, "Rebuild of table completed") > 0 Then
  'SendMail "Job completed", "False"
'Else
  'SendMail "Job failed.", "True"
'End If
'wscript.quit

If Instr(strText, "Read text of log file") > 0 Then
  SendMail "Job Completed", "False"
ElseIf Instr(strText, "Text") > 0 Then
    SendMail "No Rebuild Necessary", "False1"
Else
    SendMail "The job failed on server.", "True"
End If 
wscript.quit

Sub SendMail(strBody, result)
  YourSMTPServer = "smtpserver"
  Recipient = "Me@me.com"
  Sender = "Me@me.com"

  If result = "False" Then
    strSubject = "Job completed on backup server"
  ElseIf result = "False1" Then
    strSubject = "No table rebuild necessary on backup server"
  Else
    strSubject = "Job failed on backup server"
  End If

  set iMsg = CreateObject("CDO.Message")
  set iConf = CreateObject("CDO.Configuration")
  Set Flds = iConf.Fields

  With Flds
    .Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
    .Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtpserver"
    .Item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 10
    .Update
  End With


  With iMsg
    Set .Configuration = iConf
    If Not IsEmpty (Recipient) Then .To = Recipient
    If Not IsEmpty (Sender) Then .From = Sender
    If Not IsEmpty (strSubject) Then .Subject = strSubject
    If Not IsEmpty (strBody) Then .TextBody = strBody
    .Send 
    'wscript.echo "Mail sent."
  End With
End Sub 
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 10 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 10 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros