55 lines
2.3 KiB
JavaScript
55 lines
2.3 KiB
JavaScript
// ******************************************
|
|
// * $Id$
|
|
// *
|
|
// * Uses system-variables.
|
|
// * A batchfile which sets these variables is created in fac_refresh_accept.asp
|
|
// *
|
|
// * call sequence:
|
|
// * fac_refresh_accept.asp (generate batchfile with variables)
|
|
// * refresh_accept.bat (scheduled batchfile that searches for refresh actions)
|
|
// * refresh_<custid>_test.bat (batchfile with variables for refreshing a accept-db)
|
|
// * autorefreshaccept.bat (does the import of a fresh accept-db)
|
|
// * emailonrefreshdb.js (sends an email to notify user)
|
|
// *
|
|
// ******************************************
|
|
//
|
|
var wshShell = WScript.CreateObject( "WScript.Shell" );
|
|
var strComputerName = wshShell.ExpandEnvironmentStrings("%COMPUTERNAME%");
|
|
var mailto = wshShell.ExpandEnvironmentStrings("%NOTIFYEMAIL%");
|
|
var targetdb = wshShell.ExpandEnvironmentStrings("%TARGETUSER%");
|
|
var smtp = { sendusing: wshShell.ExpandEnvironmentStrings("%SMTPSENDUSING%")
|
|
, server: wshShell.ExpandEnvironmentStrings("%SMTPSERVER%")
|
|
, port: wshShell.ExpandEnvironmentStrings("%SMTPSERVERPORT%")
|
|
};
|
|
|
|
var mailSubject = targetdb + " ververst";
|
|
var mailBody = "De gegevens van " + targetdb + " zijn ververst om: " + (new Date());
|
|
|
|
if (mailto) // nog controleren of het een geldig mailadres is?
|
|
fac_send_mail_html( mailto, mailSubject, mailBody, smtp)
|
|
|
|
|
|
function fac_send_mail_html(adrTo,strSubj,strBody, mailserver)
|
|
{
|
|
var objMail;
|
|
var sch = "http://schemas.microsoft.com/cdo/configuration/"
|
|
|
|
var iConf = new ActiveXObject("CDO.Configuration")
|
|
iConf.Fields(sch+"sendusing").Value = mailserver.sendusing;
|
|
iConf.Fields(sch+"smtpserver").Value = mailserver.server; // Wel voor ons IP-adres relay toestaan!
|
|
iConf.Fields(sch+"smtpserverport").Value = mailserver.port;
|
|
// iConf.Fields(sch+"smtpauthenticate") = 0; // anoniem
|
|
iConf.Fields.Update();
|
|
|
|
// create mail service object
|
|
objMail = new ActiveXObject("CDO.Message");
|
|
objMail.Configuration = iConf
|
|
|
|
objMail.To = adrTo;
|
|
objMail.From = "refresh@" + strComputerName + ".facilitor.nl";
|
|
objMail.Subject = strSubj;
|
|
objMail.HtmlBody = strBody;
|
|
|
|
objMail.Send();
|
|
}
|