KickJava   Java API By Example, From Geeks To Geeks.

Java > Java SE, EE, ME > javax > mail > Store

javax.mail
Class Store

java.lang.Object
  extended byjavax.mail.Service
      extended byjavax.mail.Store
See Also:
Top Examples, Source Code, ConnectionEvent, StoreEvent

public void addFolderListener(FolderListener l)
See Also:
FolderEvent
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


[692]Receive POP3 mail
By Anonymous on 2004/03/08 19:11:16  Rate
public void receiveMail ( String server, String username, String password )  {  
     javax.mail.Store store=null; 
     javax.mail.Folder folder=null; 
  
  
     try {  
       // Get the default session 
       Properties props = System.getProperties (  ) ; 
       Session session = Session.getDefaultInstance ( props, null ) ; 
  
  
       // Get a POP3 message store, and connect to it 
       store = session.getStore ( "pop3" ) ; 
       store.connect ( server, username, password ) ; 
  
  
       // Get the default folder 
       folder = store.getDefaultFolder (  ) ; 
       if  ( folder == null )  throw new Exception ( "No default folder" ) ; 
  
  
       // Get its INBOX 
       folder = folder.getFolder ( "INBOX" ) ; 
       if  ( folder == null )  throw new Exception ( "No POP3 INBOX" ) ; 
  
  
       // Open the folder for read only 
       folder.open ( Folder.READ_ONLY ) ; 
  
  
       // Get the message wrappers and process them 
       javax.mail.Message [  ]  msgs = folder.getMessages (  ) ; 
       int msgNum = msgs.length; 
        
       ... 
       // do something with the msgs 
      }  
     catch  ( Exception e )  {  
       System.err.println ( e ) ; 
      }  
     finally {  
       try {  
         if  ( folder!=null )  folder.close ( false ) ; 
         if  ( store!=null )  store.close (  ) ; 
        }  
       catch  ( Exception e )   {  
         System.err.println ( e ) ; 
        }  
      }  
    }  
  
  
 //addFolderListener


public void addStoreListener(StoreListener l)
See Also:
StoreEvent
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public abstract Folder getDefaultFolder()
                                 throws MessagingException
See Also:
IllegalStateException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public abstract Folder getFolder(String name)
                          throws MessagingException
See Also:
Folder.create(int), Folder.exists(), IllegalStateException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public abstract Folder getFolder(URLName url)
                          throws MessagingException
See Also:
IllegalStateException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public Folder[] getPersonalNamespaces()
                               throws MessagingException
See Also:
IllegalStateException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public Folder[] getSharedNamespaces()
                             throws MessagingException
See Also:
IllegalStateException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public Folder[] getUserNamespaces(String user)
                           throws MessagingException
See Also:
IllegalStateException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


protected void notifyFolderListeners(int type,
                                     Folder folder)
See Also:
notifyFolderRenamedListeners(javax.mail.Folder, javax.mail.Folder)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


protected void notifyFolderRenamedListeners(Folder oldF,
                                            Folder newF)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


protected void notifyStoreListeners(int type,
                                    String message)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public void removeFolderListener(FolderListener l)
See Also:
addFolderListener(javax.mail.event.FolderListener)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public void removeStoreListener(StoreListener l)
See Also:
addStoreListener(javax.mail.event.StoreListener)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


protected Store(Session session,
                URLName urlname)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  

Popular Tags