Oops matty made a mistake of his own...
code:
function OnEvent_Initialize(MessengerStart){
//loop through the contacts
for (var e = new Enumerator(Messenger.MyContacts); !e.atEnd(); e.moveNext()){
// write the contacts name to the file test.txt in the scripts path
AddLineToFile ('test.txt', e.item().Name);
}
}
function AddLineToFile (file, line) {
// declare fsObj has FilesystemObject
var fsObj = new ActiveXObject('Scripting.FileSystemObject');
//check if the file exists already
var fileexists = fsObj.FileExists(MsgPlus.ScriptFilesPath + '\\' + file);
//open the file
var fileObj = fsObj.OpenTextFile(MsgPlus.ScriptFilesPath + '\\' + file, (fileexists ? 8 : 2 /* Previously was set to 1 which is ForReading */), true, (-1) /* UNICODE */);
//try to write the name to the file
try { fileObj.WriteLine(line); }
catch (err) {
//Oops we have an error lets output the name and the error
Debug.Trace(line);
Debug.Trace(err.description);
}
//close the file
fileObj.Close();
//unset the fsObj
fsObj = null;
}