Because the email address of the sent message isn't provided you have to do a few checks on the message.
code:
var aEmailAddresses = new Array('johndoe@hotmail.com', 'billgates@microsoft.com');
var oChatWndMessageSent = {};
function OnEvent_ChatWndSendMessage(oChatWnd, sMessage) { oChatWndMessageSent[oChatWnd.Handle] = sMessage; }
function OnEvent_ChatWndReceiveMessage(oChatWnd, sOrigin, sMessage, nMessageType) {
if ( oChatWndMessageSent[oChatWnd.Handle] !== sMessage && sOrigin !== Messenger.MyName ) {
for ( var oContact = new Enumerator(oChatWnd.Contacts); !oContact.atEnd(); oContact.moveNext() ) {
for ( var i in aEmailAddresses ) {
if ( oContact.item().Email === aEmailAddresses[i] && oContact.item().Name === sOrigin) {
// do stuff here
}
}
}
}
}
function OnEvent_ChatWndDestroyed(oChatWnd) { delete oChatWndMessageSent[oChatWnd.Handle]; }
What this does is when you send a message it stores it in an object then because when you send a message the OnEvent_ChatWndSendMessage is called followed by the OnEvent_ChatWndReceiveMessage. So what we do is compare the sOrigin (which is the name) to your name and we check if the message that was "received" is the different from the message stored in the object. The OnEvent_ChatWndReceiveMessage occures when specific things are added to the chat history it isn't specifically when an instant message is received.