But the destination account never receives the message. Also, after calling messenger.logout(), the application continues to run. I guess there is a zombie thread running somewhere? How can I create a basic app that 1) logs in, 2) sends a message, and 3) logs out? Seems like the most basic thing...
Does the source user have to be in the destination user's contact list? Or vice-versa? I'm working toward a system that will send automated alerts over MSN. Will I need all the recipients of these alerts to have me in their contact list?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I'm trying to write a "hello world" application that just sends a simple message over MSN. Here's the code:
public static void main(String... args) {
MsnMessenger messenger = MsnMessengerFactory.createMsnMessenger("myemail@mydomain.com", "mypassword");
messenger.login();
messenger.sendText(Email.parseStr("youremail@yourdomain.com"), "Hello World!");
messenger.logout();
}
But the destination account never receives the message. Also, after calling messenger.logout(), the application continues to run. I guess there is a zombie thread running somewhere? How can I create a basic app that 1) logs in, 2) sends a message, and 3) logs out? Seems like the most basic thing...
Does the source user have to be in the destination user's contact list? Or vice-versa? I'm working toward a system that will send automated alerts over MSN. Will I need all the recipients of these alerts to have me in their contact list?
you must wait the login completed:
email = "";
motdepasse = "";
MsnMessenger messenger = MsnMessengerFactory.createMsnMessenger(email,motdepasse);
messenger.addListener(new MsnAdapter(){
@Override
public void loginCompleted(MsnMessenger messenger){
System.out.println("login completed");
}
@Override
public void contactListInitCompleted(final MsnMessenger messenger){
Email email = Email.parseStr("youremail@yourdomain.com");
//if the contact exist
if(messenger.getContactList().getContactByEmail(email) !=null)
messenger.sendText(email,"Hello World!");
messenger.logout();
}
});