Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

retrive emails as per user name using java

 
bala krishnand
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
bala krishnand
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i dont wanna use mail api -- i wanna simple code using java
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 11092
13
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic