Tuesday, July 31, 2012

read outlook message using javamail api


import java.io.*;
import java.util.Properties;
import javax.mail.*;
import javax.mail.internet.*;

public class GetMessageExample {
  public static void main(String args[]) throws Exception {
    /*
 if (args.length != 3) {
      System.err.println("Usage: java MailExample host username password");
      System.exit(-1);
    }
*/
    String host = "email.tieto.com";
    String username = "ap\\bhatikau";
    String password = "admin1@#a";

    // Create empty properties
    Properties props = new Properties();

    // Get session
    Session session = Session.getDefaultInstance(props, null);

    // Get the store
    Store store = session.getStore("imap");
    store.connect(host, username, password);

    // Get folder
    Folder folder = store.getFolder("INBOX");
    folder.open(Folder.READ_ONLY);

    BufferedReader reader = new BufferedReader(new InputStreamReader(
        System.in));

    // Get directory
    Message message[] = folder.getMessages();
    for (int i = 0, n = message.length; i < n; i++) {
      System.out.println(i + ": " + message[i].getFrom()[0] + "\t"
          + message[i].getSubject());

      System.out.println("Read message? [YES to read/QUIT to end]");
      String line = reader.readLine();
      if ("YES".equalsIgnoreCase(line)) {
        System.out.println(message[i].getContent());
      } else if ("QUIT".equalsIgnoreCase(line)) {
        break;
      }
    }

    // Close connection
    folder.close(false);
    store.close();
  }
}


IMAP 143
POP3 25

check using
telnet host port

Monday, January 16, 2012

Get Training in Java J2SE

Java Training

Introduction to Java

Introduction
What is Java?
Syntax
First Program

Control flows

Conditional statements
Loops and switches
Continue, Break and Returns
Command Line Arguments

OOPS Concepts

Inheritance
Interface
Classes
Objects
Polymorphism
Function Overloading
Overriding
Packages

String Manipulations

String class
StringBuffer Class
StringBuilder Class
String Tokenizer
Regular Expression
String Application

Generics & Exceptions

Collections and Mapping
Utilities and Algorithms
Parameterized types
Handling Exceptions
Throws and throw
Effective Hierarchy

File IO

File Managements
File Streams
Data Streams
Stream Tokenization
Random Access Files

Threads & Serializations

The Thread Class
Assigning priority
Threads and Swing
Synchronization

Java Networking

Networking Basics
Internet Streams
Socket Programming
Remote Method Invocation