Send email notification

Discuss new features and functions
Posts: 5
Joined: 17 Mar 2025

skros

who has problems with the output of Cyrillic (russian) in letters, I have finished the script
you need to add a function at the end of the script
function convert_cyr_string(str,src,dst)
' Функция принимает строку в кодировке src и возвращает в кодировке dst.
' src и  dst могу принимать следующие значения: "d", "w", "u" - 866, 1251 и UTF соответственно.

   src = lcase(src)
   dst = lcase(dst)
   dim Fsrc, Fdst, ArrFdos, ArrFwin, ArrFutf, d, Simv, n
   ArrFdos = split("128;129;130;131;132;133;134;135;136;137;138;139;140;141;142;143;144;145;146;147;148;149;150;151;152;153;154;155;156;157;158;159;160;161;162;163;164;165;166;167;168;169;170;171;172;173;174;175;224;225;226;227;228;229;230;231;232;233;234;235;236;237;238;239;240;241",";")
   ArrFwin = split("192;193;194;195;196;197;198;199;200;201;202;203;204;205;206;207;208;209;210;211;212;213;214;215;216;217;218;219;220;221;222;223;224;225;226;227;228;229;230;231;232;233;234;235;236;237;238;239;240;241;242;243;244;245;246;247;248;249;250;251;252;253;254;255;168;184",";")
   ArrFutf = split("208:144;208:145;208:146;208:147;208:148;208:149;208:150;208:151;208:152;208:153;208:154;208:155;208:156;208:157;208:158;208:159;208:160;208:161;208:162;208:163;208:164;208:165;208:166;208:167;208:168;208:169;208:170;208:171;208:172;208:173;208:174;208:175;208:176;208:177;208:178;208:179;208:180;208:181;208:182;208:183;208:184;208:185;208:186;208:187;208:188;208:189;208:190;208:191;209:128;209:129;209:130;209:131;209:132;209:133;209:134;209:135;209:136;209:137;209:138;209:139;209:140;209:141;209:142;209:143;208:129;209:145",";")
   if (src = "w" and dst = "w") or (src = "d" and dst = "d") or (src = "u" and dst = "u") then
      convert_cyr_string = str
      exit function
   end if
   if src = "w" then
         Fsrc = ArrFwin
      elseif lcase(src) = "d" then
         Fsrc = ArrFdos
      elseif lcase(src) = "u" then
         Fsrc = ArrFutf
      else
         convert_cyr_string = "Err: The variable src isn't true"
         exit function
   end if
   if dst = "w" then
         Fdst = ArrFwin
      elseif dst = "d" then
         Fdst = ArrFdos
      elseif dst = "u" then
         Fdst = ArrFutf
      else
         convert_cyr_string = "Err: The variable dst isn't true"
         exit function
   end if
   Set d = CreateObject("Scripting.Dictionary")
   for n=0 to ubound(Fsrc)
         d.Add Fsrc(n), Fdst(n)
   next
   if (src = "w" and dst = "d") or (src = "d" and dst = "w") then
      for n = 1 to len(str)
         if d.item(cStr(asc(mid(str,n,1)))) <> "" then
            Simv = Simv & chr(d.item(cStr(asc(mid(str,n,1)))))
         else
            Simv = Simv & mid(str,n,1)
         end if
      next
   elseif src = "u" then
      for n = 1 to len(str)
         if asc(mid(str,n,1)) = 208 or asc(mid(str,n,1)) = 209 then
            Simv = Simv & chr(d.Item(cStr(asc(left(mid(str,n,2),1)) & ":" & asc(right(mid(str,n,2),1)))))
            n = n + 1
         else
            Simv = Simv & mid(str,n,1)
         end if
      next
   elseif dst = "u" then
      for n = 1 to len(str)
         if d.item(cStr(asc(mid(str,n,1)))) <> "" Then
            Simv = Simv & chr(left(d.item(cStr(asc(mid(str,n,1)))),3)) & chr(right(d.item(cStr(asc(mid(str,n,1)))),3))
         else
            Simv = Simv & mid(str,n,1)
         end if
      next
   end if
   set d = Nothing
   convert_cyr_string = Simv
end function
then add the line three times in the script
sLine=convert_cyr_string(sLine,"u","w")
after each line where the line is present - sLine = objFil.ReadLine

here is the reworked piece of code
' CHECK LOG FILE
Select Case sLogFile
    Case "None"
        If DoDebug Then WScript.Echo sErrLogNotCfgrd
        oMsg.HTMLBody = oMsg.HTMLBody & "<br><br>" & sErrLogNotCfgrd
    Case ""
        If DoDebug Then WScript.Echo sErrLogNotFound
        oMsg.HTMLBody = oMsg.HTMLBody & "<br><br>" & sErrLogNotFound
    Case Else
        oMsg.HTMLBody = oMsg.HTMLBody & "<br><br>" & "Log File: " & sLogFile
       
        ' IF WE DIDN'T COMPLETE SUCCESSFULLY, THEN SCAN FOR ERRORS AND WARNINGS
        If iExitCode <> 0 Then
            Dim objFS, objFil, sLine, DoRead
            oMsg.HTMLBody = oMsg.HTMLBody & "<br><br>" & "Error(s) and/or Warning(s)" & "<br>" & "____________________________"
            If DoDebug Then WScript.Echo "Scanning Log File"
            Set objFS = CreateObject("Scripting.FileSystemObject")
            Set objFil = objFS.OpenTextFile(sLogFile, 1) ' OPEN LOG FILE FOR READING
            DoRead = True
            Do Until objFil.AtEndOfStream
                If DoRead Then sLine = objFil.ReadLine
               
                sLine=convert_cyr_string(sLine,"u","w")        <=========
               
                DoRead = True
                If DoDebug Then WScript.Echo "Readline1 = " & sLine
                If InStr(sLine, sLogFileError       ) > 0 _
                Or InStr(sLine, sLogFileWarning     ) > 0 _
                Or InStr(sLine, sLogFileSeriousError) > 0 Then
                    If ( InStr(sLine, sLogFileError       ) > 0 And IncludeErrorsInReport   ) _
                    Or ( InStr(sLine, sLogFileWarning     ) > 0 And IncludeWarningsInReport ) _
                    Or ( InStr(sLine, sLogFileSeriousError) > 0 And IncludeErrorsInReport   ) Then
                            oMsg.HTMLBody = oMsg.HTMLBody & "<br><br>" & sLine
                    End If
                    If Not objFil.AtEndOfStream Then
                        sLine = objFil.ReadLine
                        sLine=convert_cyr_string(sLine,"u","w")        <=========
                        If DoDebug Then WScript.Echo "Readline2 = " & sLine
                        Do Until objFil.AtEndOfStream Or Left(sLine,1) = "["
                            oMsg.HTMLBody = oMsg.HTMLBody & "<br>" & sLine
                            sLine = objFil.ReadLine
                            sLine=convert_cyr_string(sLine,"u","w")        <=========
                            If DoDebug Then WScript.Echo "Readline3 = " & sLine
                        Loop
                        DoRead = False
                    End If
                End If
            Loop
            objFil.Close
        End If
End Select
many thanks to the author of the script
You do not have the required permissions to view the files attached to this post.