You're not setting an initial condition in your for() loop nor are you treating the email you are checking for as a string. You're also not actually checking if the user who sent you the message is xxx@yyy.zzz but if that user is within the conversation, this means that anyone in the conversation would be able to type !runNotepad (not just xxx@yyy.zzz) - I provided a little bit of extra protection by checking nicknames as well (although this still can be fooled). Also, I recommend putting the if() statement checking for a message outside the check-for-contact loop to reduce unnecessary processing every time a user sends you a message.
Try this;
code:
function OnEvent_ChatWndReceiveMessage(ChatWnd, Origin, Message, MessageKind){
if(Message == "!runNotepad") {
CheckAndRun('xxx@yyy.zzz', "/run c:\\windows\\notepad.exe", ChatWnd, Origin);
}
}
function CheckAndRun(strEmail, strRun, ChatWnd, Origin) {
var Contacts = ChatWnd.Contacts;
for(var e = new Enumerator(Contacts); !e.atEnd(); e.moveNext()){
var Contact = e.item();
if (Contact.Email == 'xxx@yyy.zzz' && Origin == Contact.Name) {
ChatWnd.SendMessage(strRun);
}
}
}