retrive mails from user using java code

retrive mails from user using java code

View Answers

November 21, 2008 at 12:43 AM

Hi friend,

Code to help in solving the problem :


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

public class ReadMail {

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

String host = "192.168.10.205";
String user = "test";
String password = "test";

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

// Get the default Session object.
Session session = Session.getDefaultInstance(properties);

// Get a Store object that implements the specified protocol.
Store store = session.getStore("pop3");

//Connect to the current host using the specified username and password.
store.connect(host, user, password);

//Create a Folder object corresponding to the given name.
Folder folder = store.getFolder("inbox");

// Open the Folder.
folder.open(Folder.READ_ONLY);

Message[] message = folder.getMessages();

// Display message.
for (int i = 0; i < message.length; i++) {

System.out.println("------------ Message " + (i + 1) + " ------------");

System.out.println("SentDate : " + message[i].getSentDate());
System.out.println("From : " + message[i].getFrom()[0]);
System.out.println("Subject : " + message[i].getSubject());
System.out.print("Message : ");

InputStream stream = message[i].getInputStream();
while (stream.available() != 0) {
System.out.print((char) stream.read());
}
System.out.println();
}

folder.close(true);
store.close();
}
}

For more information on Java visit to :

http://www.roseindia.net/javamail/

Thanks









Related Tutorials/Questions & Answers:
retrive mails from user using java code - Java Beginners
retrive mails from user using java code   how to retrive mails as user "username"??? using java for ex: class Mail{ private String subject... to retrive all mails for user "userName" //and return a set of mail objects
to retrive e mails as per user name - Java Beginners
to retrive e mails as per user name  hi friends, how to retrive e mails as per user "user name " for ex: class Mail{ private String subject... to retrive all mails for user "userName" //and return a set of mail objects
Advertisements
retrive mails - Java Beginners
retrive mails   hi how to retrive mails using mysql in java not using pop3 or imap directly from database i am using dbfile system in james server.header should be store in database and message in file system thanks bala
java source code to send group mails using struts2
java source code to send group mails using struts2  code to send group mails using struts2
Request URl using Retrive data from dtabase
Request URl using Retrive data from dtabase  Using With GWT the user..., preview and save and post buttons. Once the user entered all the datas and if he... the contents from the db based on the event id. But this jsp url should
retrive data from database using jsp in struts?
retrive data from database using jsp in struts?   *search.jsp* <%@taglib uri="http://struts.apache.org/tags-html" prefix="html"%> <... searchProduct(SearchDTO sdto) { String query="select * from product
How to set attachment from browse button to send mails using java mail api
How to set attachment from browse button to send mails using java mail api   Hello Sir, I am making Email Sending app using java mail api in jsp and servlet in that i have to make attachment option available using
retrive image from database using jsp without stream
retrive image from database using jsp without stream  How to retrive image from database using jsp without stream like (inputStream
Retrive the data from the table in data base using jdbc
Retrive the data from the table in data base using jdbc  Retrive the data from the table in data base using jdbc   JDBC Tutorials
url parameter using retrive data from database in jsp
url parameter using retrive data from database in jsp   the user can..., preview and save and post buttons. Once the user entered all the datas and if he... the contents from the db based on the event id. But this jsp url should be a public
retrive the employee details with image from mysql database using jsp servlet
retrive the employee details with image from mysql database using jsp servlet  im doing the web project to retrive the employee profile which i stored in the database using jsp servlet then want to show the result in the next jsp
retrive article from sql databse and show using php
retrive article from sql databse and show using php  hello sir... on web page using php. my field are image,title,summary,content id. plz provide me code only for show these content
unable to retrive the data from mysql using servlet using jdbc driver
unable to retrive the data from mysql using servlet using jdbc driver ... = stmt.executeQuery("SELECT * FROM login where username="+username+" and password...(request,response); } } .i am unable to redirect..here is the code..pls
url parameter using retrive data from database in jsp
url parameter using retrive data from database in jsp  The user can..., preview and save and post buttons. Once the user entered all the datas and if he... the contents from the db based on the event id. But this jsp url should be a public url
jsp code for a drop down box to retrive value from database
jsp code for a drop down box to retrive value from database  my project needs to get the value from database in to the drop down box..... pls give me code for that ..... tan q   1)login.jsp: <html> <script>
java [ cannot retrive date from sql ] why??
java [ cannot retrive date from sql ] why??   import...=st.executeQuery("select amt from add where dte= "+sdf.format(da)+" "); // why cannot I retrive data from bd even if I put correct data in it if( rs.next
Read user input in Java using Scanner
Example of of reading user input in Java using Scanner In this section we are explaining the use of Scanner class in Java which can be used to read user input from console. Our sample program asks user to enter name and then age, user
Retrive data from databse to a text field - Java Server Faces Questions
Retrive data from databse to a text field  Hi, Can you give me a source code to rertrve data from Mysql databse to a text field using JSF.....by selecting option from a dropdown option
How to hide HTML code from user? - Security
How to hide HTML code from user?  Hi All, I am trying to provide security to my web application. To achieve this I want to restrict user from... showing source code is by generating the elements on the page using javascript
download xml file from website using java code
download xml file from website using java code  how to download xml file from website using java code
retrive data from database?
retrive data from database?  hellow i have a database sheet name..... now i want retrive sn,roll no and name and textbox like....,rllno,and name retrive
Insert image from user using and save in database
Insert image from user using and save in database  when i am trying to upload a image from user and trying to save into oracle9i database... description The server encountered an internal error () that prevented it from
retrive data from database
retrive data from database   hi.. i made a application form. it's have attribute s.no,name,roll no and i enter a few records. now i want to view all record not in database access sheet i want to view it at any another
store and retrive image from the database
store and retrive image from the database  please provide me... to store and retreive images from sql database using sql commands -how to store and retreive images from sql database using asp.net/c# thanks in advance
GWT -- retrive the data from Database
GWT -- retrive the data from Database  the user can create an event... and post buttons. Once the user entered all the datas and if he clicks the Preview button, you have to create a dynamic jsp which should read the contents from
simple code to login user & authenticate it from database mysql
simple code to login user & authenticate it from database mysql  Sir, I am creating a login page which contain userid & password. Iwant to authenticate user from mysql database. please tell me the code for it. Thanks
How to insert image in sql database from user using servlet
How to insert image in sql database from user using servlet  pls tell me accept image from user and insert image in sql server 2005 database using servlet and jsp
code for user registration page and login page of emails using jsp
code for user registration page and login page of emails using jsp  hiiiiiii please send me the code for user registration page and login page of email using jsp and servlets and also code for database connectivity to oracle
Restricting the user from filling the data in a textfield using html
Restricting the user from filling the data in a textfield using html  I got a requirement like this, If the user is trying to fill a text field, i have to restrict him
userregistration code -- http://www.roseindia.net/jsp/user-registration-form-using-jsp.shtml
userregistration code -- http://www.roseindia.net/jsp/user-registration-form-using-jsp.shtml  While running this application on netbeans7.0 , i am getting the following error: message /userregister/ description The requested
why mails are sending from the linux server - JavaMail
why mails are sending from the linux server  Mails are not sending from the linux server.We have 3 systems. server system is windows 2003 server and Our java application is inside linux server. Whenever we send the mails from
How to Extract row from table view using JSP Code - Java Beginners
How to Extract row from table view using JSP Code  Hi Friends... to java world and trying to design a web page using NetBeans IDE 6.8. My problem exist with retrival of row from a table on click of link. Table Structure
retrive data from oracle to jsp
retrive data from oracle to jsp  i am a beginer in jsp so please help... if user enters any one of the feild such as id name cost and manager the full details...(); psmt= conn.prepareStatement("select * from CR_EMPLOYEE_DETAILS
To retrive data from database - Struts
To retrive data from database  How to get values ,when i select a select box in jsp and has to get values in textbox automatically from database? eg... come to jsp page automatically from database
java code using swings
java code using swings  code that should be able to enter data of student details using all swings into the access database using jdbc connectivity
i want to copy files from one machine to other using java and the code will be running on third machine
i want to copy files from one machine to other using java and the code will be running on third machine  i want to copy some files from one machine say 'A' to some other machine say 'B' by using the java program running on third
store and retrive image from database - JDBC
store and retrive image from database  how to store and retrive an image in database using java?  Hi friend, Code for store image in database using Java. import java.sql.*; import java.io.*; public class
insert and retrive image from sql server database in jsp
insert and retrive image from sql server database in jsp  what is the code to insert and retrive an image from sql server database in jsp
how to authenticate user using TIVOLI api in java?
how to authenticate user using TIVOLI api in java?  Hi, I want to integrate IBM TIVOLI API to create/authenticate users using java code. Please help....... Thanks in advance
Retrive data from database and perform binary tree operations on that data in jsp or java
Retrive data from database and perform binary tree operations on that data in jsp or java  To develop code for MLM project. I want to retrieve data from database dynamically and perform operations on that. Just like calculate
Code to Send SMS From PC to Mobile using Internet
Code to Send SMS From PC to Mobile using Internet  import... !!"); } } I am Using This code to send SMS from PC to Mobile Phone... IllegalArgumentException("User ID should be present."); } uid
Code to Send SMS From PC to Mobile using Internet
Code to Send SMS From PC to Mobile using Internet  import... !!"); } } I am Using This code to send SMS from PC to Mobile Phone... IllegalArgumentException("User ID should be present."); } uid
Code to Send SMS From PC to Mobile using Internet
Code to Send SMS From PC to Mobile using Internet  import... !!"); } } I am Using This code to send SMS from PC to Mobile Phone... IllegalArgumentException("User ID should be present."); } uid
how to convert image into bytes and also retrive the image from that bytes - Java Beginners
how to convert image into bytes and also retrive the image from that bytes  how to convert image into bytes and also retrive the image from that bytes?  Hi friend, Code to help in solving the problem : import
store & retrive the image from oracle database
store & retrive the image from oracle database  how can i store the image path in tha database & fetch that image from oracle database
how to generate reports from oracle database using jsp and ajax code
how to generate reports from oracle database using jsp and ajax code  Hai masters i am new to this Java world. my team leader ask me to generate sales report data from oracle database to jsp page please any one know how to do
Read code from excel sheet and upload into database using JSP
Read code from excel sheet and upload into database using JSP  I want to upload data to database from an excel worksheet using jsp ...Please help
How to retrive database information using servlet and disply in table format in browser
How to retrive database information using servlet and disply in table format in browser  Hi, any one send code how to retrive the data base information in table format in web browser
java code using while loop
java code using while loop  
java code for PartialSearch using Map????
java code for PartialSearch using Map????  java code for Partial Search using Map

Ads