dcsimg
getting a folder to read mail
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Susanta_Dash
Posted On:   Wednesday, October 2, 2002 11:11 PM

import java.util.*; import java.io.*; import java.lang.String.*; import javax.mail.*; import javax.mail.internet.*; import javax.activation.*; public class FolderMgmt { static String proto="pop3"; static String host="111.111.111.123"; //static String port="110"; static String root="HOME/AMIT/INBOX/"; static String pattern ="%"; static boolean recursive =false; int a1,a2,a3; FolderMgmt()throws Exception { Properties props = System.getProperties(); Session session = Session.getDefaultInstance(props, null); Store store=null ; // Folder folder=null;    More>>

import java.util.*;
import java.io.*;
import java.lang.String.*;
import javax.mail.*;
import javax.mail.internet.*;
import javax.activation.*;

public class FolderMgmt
{
static String proto="pop3";
static String host="111.111.111.123";
//static String port="110";
static String root="HOME/AMIT/INBOX/";
static String pattern ="%";
static boolean recursive =false;
int a1,a2,a3;
FolderMgmt()throws Exception
{
Properties props = System.getProperties();
Session session = Session.getDefaultInstance(props, null);
Store store=null ;
// Folder folder=null;
store = session.getStore(proto);

//store.connect(host, 110,"root","root123");
store.connect(host, 110,"amit","amitsingh");

System.out.println("Connected>>>>.");
Folder rf = store.getFolder("HOME/AMIT/INBOX");
//zzzzz

try{
rf.open(Folder.READ_WRITE);
}catch(MessagingException s123){s123.printStackTrace();
rf.open(Folder.READ_ONLY);
}
int n=rf.getMessageCount();
System.out.println(n);
/*Message []msg=rf.getMessages();
//FetchProfile fp=new FetchProfile();
fp.add(FetchProfile.Item.ENVELOPE);
rf.fetch(msg,fp);
for(int i=0; i
{
System.out.println(msg[i].getFrom());
}*/

/*if((rf.getType() & Folder.HOLDS_MESSAGES) != 0)
{
if (rf.hasNewMessages())
{*/
System.out.println("Has New Messages");
System.out.println("Has Messages"+rf.getMessageCount());
}
/*static void dumpFolder(Folder folder, boolean recurse, String tab)
throws Exception
{
System.out.println( "Name: " + folder.getName());
System.out.println( "Full Name: " + folder.getFullName());
System.out.println( "URL: " + folder.getURLName());
if (!folder.isSubscribed())
System.out.println(tab + "Not Subscribed");
if((folder.getType() & Folder.HOLDS_MESSAGES) != 0)
{
if (folder.hasNewMessages())
System.out.println(tab + "Has New Messages");
folder.getMessageCount());
System.out.println(tab + "Total Messages: " +
System.out.println(tab + "New Messages: "+ folder.getNewMessageCount());
System.out.println(tab + "Unread Messages: " + folder.getUnreadMessageCount());
}
if ((folder.getType() & Folder.HOLDS_FOLDERS) != 0)
System.out.println(tab + "Is Directory");
if ((folder.getType() & Folder.HOLDS_FOLDERS) != 0) {
if (recurse) {
Folder[] f = folder.list();
for (int i=0; i < f.length; i++)
dumpFolder(f[i], recurse, tab + " ");
}
}
}*/

public static void main(String argv[])
{
System.out.println("Connecting.....");
try
{
FolderMgmt fm =new FolderMgmt();
}
catch(Exception me){System.out.println(me.getMessage());}
}
}

//it is givving folder not found exception and message that folder is not inbox but my inbox is in path home/amit/inbox

   <<Less

Re: getting a folder to read mail

Posted By:   Christopher_Koenigsberg  
Posted On:   Thursday, October 3, 2002 08:15 AM

I think with a POP server, the only folder name you can use is "INBOX".

About | Sitemap | Contact