Menu

Can't even get basic funcitonality to work?

Help
2009-08-22
2013-04-29
  • Philippe DesRosiers

    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?

     
    • Anonymous

      Anonymous - 2009-08-22

      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();
          }
      });

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.