Send email notification

Discuss new features and functions
User avatar
Zenju
Site Admin
Posts: 3867
Joined: 9 Dec 2007

Post by Zenju • 18 Jan 2013, 20:36

A user sent me a script which may be useful for admins who want to run FreeFileSync and send a status report via email:

>I needed email notification containing log warnings and errors, so I wrote the attached VBS. It is probably not bug-free as I could test it only in my environment, but you are welcome to it. If it's something you would like to distribute to add value to your product, fell free to do so.
Again, thank you.
Lane Beneke
Attachments
FreeFileSync.vbs
(10.99 KiB) Downloaded 431 times

nodough
Posts: 10
Joined: 17 Sep 2013

Post by nodough • 22 Jan 2015, 20:34

Hi All,

I've updated this script several times and thought it might be a good idea to upload the updated version.

Enjoy,
NoDough

Edit: Attachment removed in favor of newer version below.

eahm
Posts: 16
Joined: 13 Apr 2014

Post by eahm • 14 Feb 2015, 19:30

Hi, thank you for this. Few questions:

1) Do I have to put this file on "On completion:"? Just exactly like a .bat file?

2) Do I have to create multiple copies based on how many profiles I have? With different names?

3) How can I use it with the Gmail SMTP (SSL, Auth etc.)?

Thank again.

nodough
Posts: 10
Joined: 17 Sep 2013

Post by nodough • 24 Apr 2015, 12:23

Hello All,

Posting yet another update to the script. The most obvious change is I've added duration to the report.

eahm, I'll attempt to answer your questions.

1) The script will execute FreeFileSync.exe and wait for it to terminate. How it terminates is up to you, but the script will not continue until it does.

2) I like to divide my ffs_batch files up according to their task. But there's no reason you couldn't dump all your tasks into a single ffs_batch file.

3) Good question. I have no idea. But this site appears to guide you through it.

Enjoy!

Edit: Removed file attachment in favor of newer version below.
Last edited by nodough on 07 Apr 2016, 16:06, edited 1 time in total.

berettatim
Posts: 1
Joined: 10 Nov 2014

Post by berettatim • 29 Sep 2015, 09:50

If for someone could help....
You could update the script to send email with more paramenters of authentication, I found this:

Const SMTPServer = "yourserver.yourdomain.com"
Const SMTPAuth = 1
Const SMTPPort = 25
Const SMTPUsername = "your.smtp.username"
Const SMTPPassword = "your.smtp.password"


oMsg.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = SMTPServer
oMsg.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = SMTPAuth
oMsg.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = SMTPPort
oMsg.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 'SendUsingPort
oMsg.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = SMTPUsername
oMsg.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = SMTPPassword

Dim ArgArray(10,1)


ArgArray(6,0) = "SMTPServer"
ArgArray(6,1) = "oMsg.Configuration.Fields.Item(""http://schemas.microsoft.com/cdo/configuration/smtpserver"")"
ArgArray(7,0) = "SMTPAuth"
ArgArray(7,1) = "oMsg.Configuration.Fields.Item(""http://schemas.microsoft.com/cdo/configuration/smtpauthenticate"")"
ArgArray(8,0) = "SMTPPort"
ArgArray(8,1) = "oMsg.Configuration.Fields.Item(""http://schemas.microsoft.com/cdo/configuration/smtpserverport"")"
ArgArray(9,0) = "SMTPUsername"
ArgArray(9,1) = "oMsg.Configuration.Fields.Item(""http://schemas.microsoft.com/cdo/configuration/sendusername"")"
ArgArray(10,0) = "SMTPPassword"
ArgArray(10,1) = "oMsg.Configuration.Fields.Item(""http://schemas.microsoft.com/cdo/configuration/sendpassword"")"

teymur-bagirov
Posts: 2
Joined: 14 Nov 2015

Post by teymur-bagirov • 14 Nov 2015, 12:24

we use blat (command line smtp sender)
the next line in bat file after FFS is blat, which sends log.
that's it

nodough
Posts: 10
Joined: 17 Sep 2013

Post by nodough • 07 Apr 2016, 16:14

I've updated the script and attached it to this message. Updates include...

Added the fields for SMTP authentication.
Modified the Email send process to retry on failure.
Fixed bug finding log files.
Fixed bug calculating elapsed time.
Added server name and batch name to body of report.

NoDough

P.S.: Two users have inquired how to send the entire log file. This script is not designed to send the entire log file. The purpose of this script is to send only the errors and warnings when things go wrong.
Attachments
FreeFileSync.vbs
(20.3 KiB) Downloaded 513 times

FileSyncExpert
Posts: 17
Joined: 31 Mar 2016

Post by FileSyncExpert • 15 Apr 2016, 07:08

Thanks for sharing this. I worked on an similar Project with autohotkey. Its a beta Version.
When its done, i will share this to... I hope that it does not take longer than 2 - 3 Weeks...

hughc
Posts: 2
Joined: 13 Apr 2016

Post by hughc • 12 May 2016, 02:24

great script!

I modified it slightly to work with gmail as the SMTP provider, as SSL is required; adding an SSL param was not difficult, but I did not bother to expose it as a command line argument (for my end use) just a configuration constant:

Code: Select all

Const SMTPSsl = 1
...
oMsg.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = SMTPSsl
Hope that might help anyone making use.

As an aside, if you set up a dummy gmail account just for the purposes of sending the mail, you will need to enable the 'Less Secure Apps setting in order that mail be sent.

Image
cheers,
Hugh

JonBenavides
Posts: 1
Joined: 9 Jun 2016

Post by JonBenavides • 09 Jun 2016, 18:41

it is possible to attach the last log file in email?

timberetta
Posts: 1
Joined: 29 Apr 2016

Post by timberetta • 21 Jul 2016, 13:23

Is it possible to insert in the subject the tag [Warning] or [Error] if the exiterror code is it?
Pls anyone could help?
Thank you.

serendipityguy
Posts: 21
Joined: 9 Aug 2016

Post by serendipityguy • 09 Aug 2016, 16:56

JonBenavides wrote:it is possible to attach the last log file in email?
I guess that some of the log files are too large for email depending on the size of your backup disk.

serendipityguy
Posts: 21
Joined: 9 Aug 2016

Post by serendipityguy • 09 Aug 2016, 16:58

Zenju wrote:A user sent me a script which may be useful for admins who want to run FreeFileSync and send a status report via email:
Lane Beneke
Could this be added into the next build as a feature request? Thanks for sharing Lane.