Quantcast
Channel: Active questions tagged email - Stack Overflow
Viewing all articles
Browse latest Browse all 29748

Vbscript: Vbs file doesnt even respond when i click on it ...it doesnt even show an error window---> idk what is wrong

$
0
0
Option Explicit

' Function you can call every time to add item to an array
Function AddItem(arr, val)
    ReDim Preserve arr(UBound(arr) + 1)
    arr(UBound(arr)) = val
    AddItem = arr
End Function
REM Used like so:
REM a = Array()
REM a = AddItem(a, 5)
REM a = AddItem(a, "foo")

' Function you can call every time to add item to an array
Sub Add(arr, val)
    ReDim Preserve arr(UBound(arr) + 1)
    arr(UBound(arr)) = val
    End Sub
REM Used like so:
REM a = Array()
REM a = AddItem(a, 5)
REM a = AddItem(a, "foo")



REM defining an array that stores boolean values
Dim H(6)
REM giving array values
H(0) = TRUE : H(1) = FALSE : H(2) = TRUE : H(3) = FALSE : H(4) = TRUE : H(5) = FALSE : H(6) = TRUE
REM -------------------------------------------------------------------------------------------------------------------------------------------------------------
REM defining an array that stores string values
Dim J(6)
REM giving array values
J(0) = "Izklop v sili" : J(1) = "Presostat" : J(2) = "Nivo olja" : J(3) = "Nivo Freona" : J(4) = "Int zaščita" : J(5) = "potrditev delovanja" : J(6) = " ventilator int"
REM -------------------------------------------------------------------------------------------------------------------------------------------------------------
ReDim K(0) REM defining empty array which will store Text_Body of email
REM -------------------------------------------------------------------------------------------------------------------------------------------------------------

REM FIRST LOOP 
Dim intCounter   REM Variable used to control a For...Each loop

For intcounter = 0 TO 6
IF H(intcounter) = True Then
AddItem K,intcounter
AddItem K,J(intcounter)
END IF
Next
REM End of first  for TO next loop .........


REM We now wait the first loop to end......and than check if there was any alarm active

Dim i  REM defining variables which will serve as counters
Dim c  REM defining variables which will serve as counters

If intcounter > 6 Then 
For i = 0 TO 6
If K(i) = TRUE Then
c = c + 1
END IF 
next
END IF

Dim Text_Body REM defining variable which will serve as email HTMLBody
Dim Alarm  REM Defining a variable which will serve as condition to send email

IF c > 0 Then 
Text_Body = Join( K, ",")
Alarm = True
END IF 

IF Alarm = True  Then
'Create the objects require for sending email using CDO
Set objMail = CreateObject("CDO.Message")
Set objConf = CreateObject("CDO.Configuration")
Set objFlds = objConf.Fields

objMail.Configuration = objConf
objMail.From = ""
objMail.To = ""
objMail.Subject = "Put your email's subject line here"
objMail.TextBody = "Your email body content goes here"'Set various parameters and properties of CDO object
objFlds.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 'cdoSendUsingPort
'your smtp server domain or IP address goes here such as smtp.yourdomain.com
objFlds.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.gmail.com"
objFlds.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 465
'uncomment next three lines if you need to use SMTP Authorization
objFlds.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = ""
objFlds.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = ""
objFlds.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1 'cdoBasic
objFlds.Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = 1
objFlds.Update

REM Now send the message

On error Resume Next
objMail.Send

IF err.Number <> 0 Then
 Alarm = FALSE
 intCounter = 0
 i = 0
 c = 0
MsgBox Err.Description,16,"Error sending Mail "
Else
 Alarm = FALSE
 intCounter = 0
 i = 0
 c = 0
END IF

'Set all objects to nothing after sending the email
Set objFlds = Nothing
Set objConf = Nothing
Set objMail = Nothing

END IF

I am trying to put together a script ...to check for the alarms in the system ...and if there is an alarm or multiple alarms present in the system ....the script then sends an email with the description of the active alarms inside email TextBody. But somehow...this script dont even want to start....it doesnt even show error window...i click in vbs file and nothing happens. Please help


Viewing all articles
Browse latest Browse all 29748

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>