Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 459 Vote(s) - 3.52 Average
  • 1
  • 2
  • 3
  • 4
  • 5
CDO CreateMHTMLBody locks the file in JScript

#1
I'm making a JScript script that sends e-mail messages in HTML format via CDO. I have a message template in .html file, and I put some unique data into each message being sent. So, I create a copy of the original .html file for each message.

The problem is that I cannot detele this temporary file from within script after sending the message. I've checked with ProcessExplorer, which process locks the file, and it is cscript.exe/wscript.exe (wichever is being used to run the script).

Here is the example (simplified) code:

//-------------------------------------------
var fso = new ActiveXObject("Scripting.FileSystemObject");
var BodyFileName = fso.GetAbsolutePathName(WScript.Arguments(3));
var BodyExtensionName = fso.GetExtensionName(BodyFileName)
var BodyFile = fso.OpenTextFile(BodyFileName, 1);
var Body = BodyFile.ReadAll();
BodyFile.Close();
//-------------------------------------------
// Replace something in Body here
//-------------------------------------------
BodyFileName = fso.BuildPath(fso.GetParentFolderName(BodyFileName), fso.GetTempName() + "." + BodyExtensionName);
var TmpBodyFile = fso.OpenTextFile(BodyFileName, 2, true);
TmpBodyFile.Write(Body);
TmpBodyFile.Close();
// Here ProcessExplorer shows that the file is closed
//-------------------------------------------
var objEmail = new ActiveXObject("CDO.Message");
objEmail.From = WScript.Arguments(0);
objEmail.To = WScript.Arguments(1);
objEmail.Subject = WScript.Arguments(2);
objEmail.CreateMHTMLBody("file:///" + BodyFileName.replace("\\","/"));
// Here the file is open again
objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2;
objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "192.168.0.1";
objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25;
objEmail.Configuration.Fields.Update();
objEmail.Send();
objEmail = null;
//-------------------------------------------
// The following loop becomes endless
for (;;) {
try {
fso.DeleteFile(BodyFileName, true);
} catch(e) {
WScript.Sleep(100);
continue;
} finally {
}
break;
}
//-------------------------------------------

Thanks.
Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through