Send email notification

Discuss new features and functions
Posts: 68
Joined: 13 Aug 2018

TheExpert

Yes, this is possible. But again, you can't be sure that the script has finished before the computer is shutting down. And the shutdown is then always waiting the delay time even if it's not needed. For example when the sync is successful and the mail script doesn't have to search for errors in the log files.

For me it's OK if you set the shutdown in the FFS batch. This is very easy because you even don't need to write a script. But it may be not the best solution under all circumstances.
Posts: 11
Joined: 10 Aug 2021

bdum

How to set in the ffs batch? Shutdown with delay?
User avatar
Posts: 2607
Joined: 22 Aug 2012

Plerry

At the bottom of the Synchronization Settings (F8) in the FFS GUI you find the "Run a command" option, where you select the condition to run the command, and to specify the command.
Posts: 3
Joined: 25 Nov 2021

grovebaby

we use blat (command line smtp sender)
the next line in bat file after FFS is blat, which sends log.
that's it teymur-bagirov, 14 Nov 2015, 12:24
Hi, you still around. I tried to download BLAT, but get a Sandbox malware warning from our ZScaler sw.
Posts: 19
Joined: 8 Nov 2018

sagitario

Hi,
Is there any way for the script to accept special characters, such as "ã". I'm trying to translate to Portuguese, but it doesn't accept some words that have special characters.
Thanks,
Posts: 19
Joined: 8 Nov 2018

sagitario

Hi,
Is there any way for the script to accept special characters, such as "ã". I'm trying to translate to Portuguese, but it doesn't accept some words that have special characters.
Thanks, sagitario, 11 Apr 2022, 17:25
Ok, I managed to get the texts in the script to appear correctly by saving the script in ANSI format instead of UTF8 format. I don't know if it's the perfect solution, but it partially solved the problem. However, in the list of errors, the crazy characters still appear. When consulting the TXT log file, the text is show correct, even though the log file is in UTF8 format. Is it possible for the characters to all appear correctly?

Thanks,
Posts: 5
Joined: 16 Nov 2022

alefello

Hello everybody

I've two small problems with this script.

1st: I'm using it on many PCs and servers, with gmail as mail server, without an issue, but on a server with Windows Server 2022 it doesn't work. I suspect something is wrong in my configuration or in the server configuration, but even enabling debug in the script I can't find what's wrong. Do you have any suggestion how to debug the problem?

2nd: I red (maybe wrong) that if I enable the simple text logs the script is able to report in the email the warning or error lines. Well, I enabled simple text logs in FreeFileSync options ant the logs are correctly saved in simple text *.log format, but I still receive the emails with only error or warning in the subject, but no log warning/error lines in the text. Do you have any advice?

Thank you!
Posts: 68
Joined: 13 Aug 2018

TheExpert

Regarding Windows Server 2022: I don't have an idea. Check the firewall settings regarding open ports for outgoing traffic for SMTP and SMTPS. Set the logging option for blocked connections in a file for the firewall. So you can see if there's a blocked connection by the firewall. Or there are security settings regarding VBScript.

Regarding log files: Yes, you're right. The script can only parse the text based log files of FreeFileSync and not the html logs. Have a look at the path where you save the log files. Is the same path set in the script? With the debug switch in the script you should see if the script is finfing and parsing the log files.
Posts: 5
Joined: 16 Nov 2022

alefello

Regarding Windows Server 2022: I don't have an idea. Check the firewall settings regarding open ports for outgoing traffic for SMTP and SMTPS. Set the logging option for blocked connections in a file for the firewall. So you can see if there's a blocked connection by the firewall. Or there are security settings regarding VBScript.TheExpert, 04 Aug 2023, 10:27
I'll check but I don't know if that's so simple cause in tebug mode I can see the sending email lines without errors o retrying
Regarding log files: Yes, you're right. The script can only parse the text based log files of FreeFileSync and not the html logs. Have a look at the path where you save the log files. Is the same path set in the script? With the debug switch in the script you should see if the script is finfing and parsing the log files. TheExpert, 04 Aug 2023, 10:27
The log file path is red in the batch ffs file. Could it be cause FFS switched from english to italian for the file language whei I switched from HTML logs to Text logs?
Posts: 68
Joined: 13 Aug 2018

TheExpert

Oh, you switched from English to Italian? Then the log entries are probably Italian, too. So you have to change it in the script. There you find entries for English and German. Here you have to set the Italian wordings so that the script can find the log lines with errors or warnings.
Posts: 1
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
Attachments
FreeFileSyncRus.vbs
(28.22 KiB) Downloaded 25 times