File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes retrive emails as per user name using java Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "retrive emails as per user name using java" Watch "retrive emails as per user name using java" New topic
Author

retrive emails as per user name using java

bala krishnand
Greenhorn

Joined: Nov 24, 2008
Posts: 3
write me a program to retrive the e-mails as per user name using java.
--------------------------------------------------------------
class Mail{
private String subject;
private String message;
private Date sentDate;
}
class MailRetriever{
public Mail[] getAllMails(String userName){
//Write code to retrive all mails for user "userName"
//and return a set of mail objects
}}

===========
output:
-----------
username :bala

subject message sentdate
hi this is test message 17.11.08
hi1 this is second message 16.11.08
hi2 this is third message 15.11.08

username: basker

subject message sentdate
hi this is test message 17.11.08
hi1 this is second message 16.11.08
hi2 this is third message 15.11.08
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 39529
    
  27
Welcome to JavaRanch.

This site is not a NotACodeMill, so people won't just write code for you. But we'll help you write it yourself, which will provide you with lots of learning opportunities.

So: What do you have so far? Just about all email handling in Java is done using the JavaMail API, so you should start by working through a tutorial like this one; it's very extensive.


Ping & DNS - updated with new look and Ping home screen widget
bala krishnand
Greenhorn

Joined: Nov 24, 2008
Posts: 3
i dont wanna use mail api -- i wanna simple code using java
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 39529
    
  27
Why not? Using JavaMail will be much simpler than writing all that code yourself. What you described is essentially an email client - that's not simple code at all, since you need to implement the relevant parts of the POP3 (or IMAP) protocol yourself.
bala krishnand
Greenhorn

Joined: Nov 24, 2008
Posts: 3
Originally posted by Ulf Dittmer:
Why not? Using JavaMail will be much simpler than writing all that code yourself. What you described is essentially an email client - that's not simple code at all, since you need to implement the relevant parts of the POP3 (or IMAP) protocol yourself.


i dont wanna use pop3 or imap to retrive mail..
i wanna use mail[] to get all mails using object subject , message , sent date .................
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 39529
    
  27
You will use POP3 or IMAP, because those are the only protocols email servers understand (unless you're talking about an Exchange server or something similar, and you have decided to use its proprietary protocols - which I would strongly advise against).

You still haven't said why you want to avoid JavaMail, which is really the only viable way of handling email using Java.
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 9990
    
    7

Originally posted by bala krishnand:
i dont wanna use mail api -- i wanna simple code using java


The mail API mentioned by Ulf is simple java code.


[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
 
Don't get me started about those stupid light bulbs.
 
subject: retrive emails as per user name using java
 
Similar Threads
Mark Mail as SEEN
yield() on synchronized code
How can I download emails with attachments from Gmail with java programing..(error occur)
the mails are goes to Badmail folder of the host
MessagingException: Connect failed