[Box Backup-commit] COMMIT r1881 - box/trunk/bin/bbackupd/win32

boxbackup-dev@fluffy.co.uk boxbackup-dev@fluffy.co.uk
Wed, 17 Oct 2007 13:49:48 +0100


Author: chris
Date: 2007-10-17 13:49:48 +0100 (Wed, 17 Oct 2007)
New Revision: 1881

Modified:
   box/trunk/bin/bbackupd/win32/NotifySysAdmin.vbs
Log:
Windows notify script logs an error in the System Event Log if sending 
email fails. (merges [1837])


Modified: box/trunk/bin/bbackupd/win32/NotifySysAdmin.vbs
===================================================================
--- box/trunk/bin/bbackupd/win32/NotifySysAdmin.vbs	2007-10-17 12:49:18 UTC (rev 1880)
+++ box/trunk/bin/bbackupd/win32/NotifySysAdmin.vbs	2007-10-17 12:49:48 UTC (rev 1881)
@@ -65,8 +65,10 @@
 
 Sub SendMail(from,sendto,subject,body)
 	Set objEmail = CreateObject("CDO.Message")
+	Set WshShell = CreateObject("WScript.Shell")
 	Dim cdoschema
 	cdoschema = "http://schemas.microsoft.com/cdo/configuration/"
+	
 	With objEmail
 		.From = from
 		.To = sendto
@@ -79,5 +81,15 @@
 			.Configuration.Fields.Update
 		End If
 	End With
-	objEmail.Send
+	On Error Resume Next
+	rc = objEmail.Send
+	If rc Then
+		WshShell.Exec "eventcreate /L Application /ID 201 /T WARNING " _
+			& "/SO ""Box Backup"" /D """ & args(0) _
+			& " notification sent to " & sendto & "."""
+	Else
+		WshShell.Exec "eventcreate /L Application /ID 202 /T ERROR " _
+			& "/SO ""Box Backup"" /D ""Failed to send " & args(0) _
+			& " notification to " & sendto & "."""
+	End If
 End Sub