Session addProvider Example

Session class addProvider example. This example shows you how to use addProvider method.


Session class addProvider example. public void addProvider(Provider provider) Add a provider to the session.

/*
 * @ # AddProvider.java
 * A class repersenting use to addProvider method 
 * of Session class in javax.mail package
 * version 05 July 2008
 * author Rose India 
 */
package session;

import java.util.*;
import javax.mail.*;

public class AddProvider {

    public static void main(String args[]) throws Exception {

        String host = "192.168.10.205";
        String from = "test@localhost ";
        String to = "test@localhost ";

        //Get all properties from system
        Properties properties = System.getProperties();

        //Create session object
        Session session = Session.getDefaultInstance(properties);

        //Provider type
        Provider.Type type = Provider.Type.STORE;

        String protocol = "imap";
        String classname = "com.sun.mail.imap.IMAPStore";
        String vendor = "roseindia ";

        Provider provider = new Provider(type, protocol, classname, vendor, null);

        //Add provider
        session.addProvider(provider);

        Provider pro[] = session.getProviders();
        System.out.println(pro[pro.length-1]);
    }
}

Output
javax.mail.Provider[STORE,imap,com.sun.mail.imap.IMAPStore,roseindia ]

Post Comment
Name:
E-mail:
Contact no :
Comments:
  Refresh Image
Verify Image:
 
 
Your Comment's
 
 
 

HOME | COPYRIGHT | CONTACT US