• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

retrive emails as per user name using java

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i dont wanna use mail api -- i wanna simple code using java
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Bartender
Posts: 11497
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic