diff --git a/WebServer/DatabaseScripts/advwb1_applylogemail.vbs b/WebServer/DatabaseScripts/advwb1_applylogemail.vbs new file mode 100644 index 0000000..09401f9 --- /dev/null +++ b/WebServer/DatabaseScripts/advwb1_applylogemail.vbs @@ -0,0 +1,72 @@ +REM $Id$ +const scripts_src = "\\advwb2\scripts" +const logship_user = "advweb\logship" +const logship_pwd = "logship" +const strFrom = "webmip@AdvanticaGroup.com" +const strTo = "Andrew.Hardy@AdvanticaGroup.com" +const strSub = "MIP: ApplyLog" +const strSubError = "MIP: ApplyLog Error" +strBody = "ApplyLog Completed Successfully" +const strSMTP = "relay01.sleek.net" + + +ShowApplyLog scripts_src, logship_user, logship_pwd + + +Sub ShowApplyLog(strDest, strUser, strPwd) + Dim strAttachment + strAttachment = "X:\applylog.log" + + Dim strRemoteDrive + strRemoteDrive = "X:" + + 'error handling + On Error Resume Next + + Set objNetwork = CreateObject("WScript.Network") + + objNetwork.MapNetworkDrive strRemoteDrive, strDest, false, strUser, strPwd + + 'handle error + If Err.Number <> 0 Then + SendEmail strFrom, StrTo, strSubError, "Error Mapping " & strDest & ":" & Err.Description, StrSMTP + Wscript.Echo "Error number " & Err.Number & " occured: " & Err.Description + Wscript.Echo "" + Wscript.Quit Err.Number + End If + + SendEmail strFrom, StrTo, strSub, strBody, StrSMTP, strAttachment + + objNetwork.RemoveNetworkDrive strRemoteDrive + 'handle error + If Err.Number <> 0 Then + SendEmail strFrom, StrTo, strSubError, "Error Removing Remote Folder " & strRemoteDrive & ":" & Err.Description, StrSMTP + Wscript.Echo "Error number " & Err.Number & " occured: " & Err.Description + Wscript.Echo "" + Wscript.Quit Err.Number + End If + + +End Sub + +' From the book "Windows Server Cookbook" by Robbie Allen +' ISBN: 0-596-00633-0 + +Sub SendEmail(strFrom, StrTo, strSub, strBody, StrSMTP, strAttachment) + set objEmail = CreateObject("CDO.Message") + objEmail.From = strFrom + objEmail.To = strTo + objEmail.Subject = strSub + objEmail.Textbody = strBody + objEmail.AddAttachment strAttachment + objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 + objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = strSMTP + objEmail.Configuration.Fields.Update + objEmail.Send + If Err.Number <> 0 Then + Wscript.Echo "Error number " & Err.Number & " occured: " & Err.Description + Wscript.Echo "" + Wscript.Quit Err.Number + End If + WScript.Echo "Email sent" +End Sub \ No newline at end of file diff --git a/WebServer/DatabaseScripts/advwb2_applylogemail.vbs b/WebServer/DatabaseScripts/advwb2_applylogemail.vbs new file mode 100644 index 0000000..d666f15 --- /dev/null +++ b/WebServer/DatabaseScripts/advwb2_applylogemail.vbs @@ -0,0 +1,72 @@ +REM $Id$ +const scripts_src = "\\advwb1\scripts" +const logship_user = "advweb\logship" +const logship_pwd = "logship" +const strFrom = "webmip@AdvanticaGroup.com" +const strTo = "Andrew.Hardy@AdvanticaGroup.com" +const strSub = "MIP: ApplyLog" +const strSubError = "MIP: ApplyLog Error" +strBody = "ApplyLog Completed Successfully" +const strSMTP = "relay01.sleek.net" + + +ShowApplyLog scripts_src, logship_user, logship_pwd + + +Sub ShowApplyLog(strDest, strUser, strPwd) + Dim strAttachment + strAttachment = "X:\applylog.log" + + Dim strRemoteDrive + strRemoteDrive = "X:" + + 'error handling + On Error Resume Next + + Set objNetwork = CreateObject("WScript.Network") + + objNetwork.MapNetworkDrive strRemoteDrive, strDest, false, strUser, strPwd + + 'handle error + If Err.Number <> 0 Then + SendEmail strFrom, StrTo, strSubError, "Error Mapping " & strDest & ":" & Err.Description, StrSMTP + Wscript.Echo "Error number " & Err.Number & " occured: " & Err.Description + Wscript.Echo "" + Wscript.Quit Err.Number + End If + + SendEmail strFrom, StrTo, strSub, strBody, StrSMTP, strAttachment + + objNetwork.RemoveNetworkDrive strRemoteDrive + 'handle error + If Err.Number <> 0 Then + SendEmail strFrom, StrTo, strSubError, "Error Removing Remote Folder " & strRemoteDrive & ":" & Err.Description, StrSMTP + Wscript.Echo "Error number " & Err.Number & " occured: " & Err.Description + Wscript.Echo "" + Wscript.Quit Err.Number + End If + + +End Sub + +' From the book "Windows Server Cookbook" by Robbie Allen +' ISBN: 0-596-00633-0 + +Sub SendEmail(strFrom, StrTo, strSub, strBody, StrSMTP, strAttachment) + set objEmail = CreateObject("CDO.Message") + objEmail.From = strFrom + objEmail.To = strTo + objEmail.Subject = strSub + objEmail.Textbody = strBody + objEmail.AddAttachment strAttachment + objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 + objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = strSMTP + objEmail.Configuration.Fields.Update + objEmail.Send + If Err.Number <> 0 Then + Wscript.Echo "Error number " & Err.Number & " occured: " & Err.Description + Wscript.Echo "" + Wscript.Quit Err.Number + End If + WScript.Echo "Email sent" +End Sub \ No newline at end of file