bala
retrive mails from user using java code
1 Answer(s)      8 years ago
Posted in : Java Beginners

Ads

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
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 data from database using jsp in struts?
retrive data from database using jsp in struts?   *search.jsp* <[email protected] uri="http://struts.apache.org/tags-html" prefix="html"%> <... searchProduct(SearchDTO sdto) { String query="select * from product
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
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
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
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 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
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
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
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
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>
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
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
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
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
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
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
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
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
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
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
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
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
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
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