Send email notification

Discuss new features and functions
Posts: 2
Joined: 23 Mar 2020

rv67

Hello I need probably some help:
Just used the email notification available on the synchro config, but...
When errors, a popup reports the errors, and this popup needs to be closed manually before any notification is sent.

My use case: I want to be notified only when there are disk access errors (happens sometimes in my network) when I'm not in front of my computer.

Did I miss something?
Posts: 68
Joined: 13 Aug 2018

TheExpert

What is the content op the popup? Which error messages do you get? Do you use the mail notification of FreeFileSync itsself or do you use a script for getting the error messages per mail?
Posts: 2
Joined: 23 Mar 2020

rv67

Yes it's the email notification from FreeFileSync.

Issue fixed. Just to activate "ignore errors" in comparison params, and no popup and notification sent. thx.
Posts: 68
Joined: 13 Aug 2018

TheExpert

Hello all,

under viewtopic.php?f=2&t=2095&p=18563#p18563 you can find a new version of the VB script with a little bug fix.

Kind Regards

TheExpert
Posts: 2
Joined: 6 Jun 2020

mircot80

Hi everyone.
I get this error:
Image

This is line 495:
sLogFolder = Mid(sLine, x, InStr(x, sLine, "<" ) - x )
I tried with version 10.11 with Windows Server 2008 and with version 10.24 with Windows 10.

What can I do?
Thanks.
Posts: 2
Joined: 6 Jun 2020

mircot80

Hi everyone.
I get this error:
Image

This is line 495:
sLogFolder = Mid(sLine, x, InStr(x, sLine, "<" ) - x )
I tried with version 10.11 with Windows Server 2008 and with version 10.24 with Windows 10.

What can I do?
Thanks. mircot80, 06 Jun 2020, 12:57
I have solved.
I hadn't activated: "Override default log path"
Thanks.
Posts: 68
Joined: 13 Aug 2018

TheExpert

I fixed a little bug in the VBScript and uploaded the new file to viewtopic.php?f=2&t=2095&p=18563#p18563.
Posts: 2
Joined: 8 Aug 2021

sbourdon

Hello,

Thank you for this great script!
Everything is running smoothly except that the email doesn't include errors and warnings. Here's an example of emails I get:
FreeFileSync batch UniServerZ running on PC-SALON
Synchronization completed with errors

Duration: 0 seconds



Log File: C:\Users\sylva\AppData\Roaming\FreeFileSync\Logs\UniServerZ 2021-08-08 103939.273 [Error].html

Error(s) and/or Warning(s)
____________________________
Is that the way the email is supposed to look like or is it incomplete?

Thank you for you help! :)

--

EDIT: Fixed! Simply needed to select PLAIN TEXT as LOG FILE FORMAT.
Posts: 11
Joined: 10 Aug 2021

bdum

Hello,
first of all I want to thank for this script that works without problems from the first.
The only question I have, can the .xml log be inserted in the e-mail to be seen directly in it?

Like in the donation version.
a link for the screenshoot https://ibb.co/PmY1kkd
Posts: 68
Joined: 13 Aug 2018

TheExpert

It's possible to attach the log file to the mail. But does it make sense? The script searches the log file for errors and shows the complete lines of the errors in the log file if there are errors.
Posts: 11
Joined: 10 Aug 2021

bdum

Hi and thanks for replay TheExpert,
it would be helpful for the sync status and computer name to appear in the email title.
that's how it appears to me now, maybe I was wrong somewhere.
link for the screenshoot
https://ibb.co/qFsn08f
Posts: 68
Joined: 13 Aug 2018

TheExpert

Yes, I can change the script to write status and computer name to the mail title if this would be helpful. At the moment I'm on holidays. So I can't do this now. Maybe I will change the script next week. I will update this thread when the new version of the script is available.

Looking at your last screenshot I see that you set the log file to HTML format. With this setting the script can't find errors in the log file. You have to set the log file format to plain text in FreeFileSync.
Posts: 11
Joined: 10 Aug 2021

bdum

Thanks for the reply and happy holidays,I follow the topic with interest when you return.
I also set plain text but it also appears the same. i have the 2021.02.14 - Version 1.17, without major changes, I just filled in the data.
Posts: 68
Joined: 13 Aug 2018

TheExpert

Changing the log file format to plain text doesn't change the behavior of the script itsself: The mail title is the same as with HTML formated log files. But if there are errors with the synchronization all error lines in the log file are written completely to the mail body so you don't have to look into the log file itsself to see what's gone wrong.
Posts: 11
Joined: 10 Aug 2021

bdum

I set the report to be html and it appears the same, no error lines appear.
Image link
https://ibb.co/jTNBnPX
Posts: 68
Joined: 13 Aug 2018

TheExpert

As already written, you have to set plain text format for the log files in FreeFileSync. The script will then only show error lines in the mail body If there are errors.
Last edited by TheExpert on 31 Aug 2021, 10:52, edited 1 time in total.
Posts: 11
Joined: 10 Aug 2021

bdum

Hi TheExpert, now it works after I set plain text, if there are errors they appear in the e-mail.
Do you think that you can make the computer name appear in the subject of the message?
Thank you for support!
Posts: 68
Joined: 13 Aug 2018

TheExpert

Hi bdum,

good to hear that everything is now working as expected.

When I understand you right, you wish to have the status and the computer name in the subject line. Is this correct? This is possible but the subject line will then get longer. You then will not see the complete subject in many mail programs. So ist it really useful to do this?

If you want to use rules for sorting incoming mails you can do this with searching for the keywords in the mail body, too. So there's no need to have this information in the mail subject.

I didn't had time for changing the script yet regarding the status in the subject. And before doing this I will first be sure, if this is useful.

Kind Regards.
Posts: 7
Joined: 29 Apr 2016

timberval

Hi TheExpert,
look at the attachments if you approve you can update your script:
1. I create new const at row 226 so you can enable it by desire: "Const IncludeServerNameInSubject = False", change to "True" to write the name of machines in subject.
2. then at row 444 I inserted new variable for subject

I try it and seems to working fine in my server.
Attachments
FreeFileSync.vbs
(24.22 KiB) Downloaded 1977 times
Posts: 11
Joined: 10 Aug 2021

bdum

thanks timberetta. its works!

You're right TheExpert, the computer name in the subject doesn't help much. you can create the redirect rule in a folder. It would be helpful if ✔ or X also appears in the e-mail subject, where "Freefilesync result for batch batch name" already appears, it is more visible.
Posts: 7
Joined: 29 Apr 2016

timberval

thanks timberetta. its works!

You're right TheExpert, the computer name in the subject doesn't help much. you can create the redirect rule in a folder. It would be helpful if ✔ or X also appears in the e-mail subject, where "Freefilesync result for batch batch name" already appears, it is more visible. bdum, 30 Aug 2021, 19:33
It's helpful for me too to have in the subject the result of the sync.
This is what I use by default:
I modified the script and this is the subject that I like to receive, I abbreviated freefilesync to FFS, to shorten the subject of the mail : [Status] FFS results for Batchname
e.g. [Success] FFS results for mybatchname
or [Warnings] FFS results for mybatchname
or [Errors] FFS results for mybatchname
or [Aborted] FFS results for mybatchname

I left in the script the const to decide to insert the machine name at the end of subject.

TO TheExpert: I don't want to fork your script so it's up to you if you need to integrate these changes and how. Thank you
Attachments
FreeFileSync_timberval.vbs
(24.62 KiB) Downloaded 1898 times
Posts: 68
Joined: 13 Aug 2018

TheExpert

Hi all,

thank you for your ideas for changing the script and the implementations you've done. I changed now the script by adding the new constants 'IncludeServerNameInSubject' and 'IncludeSyncResultInSubject' to allow users to specify what to include in the email subject.

Here you can find the new version of the script: viewtopic.php?f=2&t=2095&p=18563#p18563

Hopefully, this is useful for you.

Kind Regards

TheExppert
Posts: 11
Joined: 10 Aug 2021

bdum

Hello. everything is fine, but less of a problem. if batch is finally set to shut down the computer, the email no longer has time to be sent, and is no longer sent ...
Posts: 68
Joined: 13 Aug 2018

TheExpert

Yes, the script doesn't support the shutdown of the system. The shutdown in the batch is triggered by FreeFileSync itself. The script is waiting for the exit of FreeFilesync and has to do some more steps after finishing the synchronization. But if FreeFileSync is shutting down the computer all these steps won't be done by the script any more.
Posts: 11
Joined: 10 Aug 2021

bdum

thanks theExpert! is there no solution? In the donated version works, I know is not the same with vbs script, I have the donated version only for 3 devices, but it would be helpful for more.
User avatar
Posts: 2251
Joined: 22 Aug 2012

Plerry

Instead of having FFS shut down your system, have FFS launch a script (*.bat, *.com, *.vbs ,...)
that first executes the task to be executed and only then shuts down the system.
Posts: 11
Joined: 10 Aug 2021

bdum

Hi Plerry, how can i do this? to close after the batch finishes? and e-mail have time to sent.
Posts: 11
Joined: 10 Aug 2021

bdum

Thanks for the idea! Nice! Job done!

I created a batch without auto-shutdown and put this vbs script at the end:
--------------------------------
Dim objShell, intShutdown
Dim strShutdown, strAbort

' -s = shutdown, -t 120 = 2 minutes, -f = force programs to close
strShutdown = "shutdown.exe -s -t 120 -f"
set objShell = CreateObject("WScript.Shell")
objShell.Run strShutdown, 0, false
Wscript.Quit
-------------------------------
now has time to email and close after.
Posts: 68
Joined: 13 Aug 2018

TheExpert

For me it's not clear what the variables 'intShutdown' and 'strAbort' are standing for because they aren't used in the rest of the code.

If the shutdown is working this way I can add an option to the script to do a shutdown, too. So it will be safe that all steps of the script are done before shutting down the computer. The analysis of the log files could take a long time if there are a lot of files and if the log files itself have a lot of lines.
User avatar
Posts: 2251
Joined: 22 Aug 2012

Plerry

OK, but then why not simply define a "shutdown" command with sufficient delay in the "On completion:" command-line in FFS (as suggested there). You may only need to increase the delay from 60 to 120 seconds.