| | |
Reading Mail
![]() |
•
•
Join Date: Jun 2004
Posts: 609
Reputation:
Solved Threads: 8
Hi everyone,
I am trying to read emails in from a stmp server without javamail api's and i so far have only managed to read the e-mail messages but i can't seem to read any attachments that come with it. I am not very sure as to how i should separate the message from the attachment. This is what i have so far
What are the necessary things that i need to do or changes to the above code in order to read the attachments correctly??
Some codings would really be helpfull
Thank You
Yours Sincerely
Richard West
I am trying to read emails in from a stmp server without javamail api's and i so far have only managed to read the e-mail messages but i can't seem to read any attachments that come with it. I am not very sure as to how i should separate the message from the attachment. This is what i have so far
Java Syntax (Toggle Plain Text)
import java.net.*; import java.io.*; public class displayMail { public static void main(String arg[]) { // // displayMail [mailServer] [user] [password] try { Socket s = new Socket(arg[0], 110); BufferedReader in = new BufferedReader( new InputStreamReader(s.getInputStream())); BufferedWriter out = new BufferedWriter( new OutputStreamWriter(s.getOutputStream())); displayMail t = new displayMail(); String msg; t.loginMail(in, out, arg[1], arg[2]); int i = t.checkMyMail(in,out); if (i==0) { System.out.println("No mail waiting."); } else { for (int j=1; j <= i; j++) { msg = t.getMail(in, out, j); System.out.println("*****"); System.out.println(msg); System.out.println("*****"); } } } catch (Exception e) { e.printStackTrace(); } } public String getMail (BufferedReader in, BufferedWriter out, int i) throws IOException { String s = ""; String t = ""; send(out, "RETR "+i); while (((s = in.readLine()) != null) &&(!(s.equals(".")))) t += s + "\n"; return t; } private void send(BufferedWriter out, String s) throws IOException { out.write(s+"\n"); out.flush(); } private String receive(BufferedReader in) throws IOException { return in.readLine(); } private void loginMail(BufferedReader in, BufferedWriter out, String user, String pass) throws IOException { receive(in); send(out, "USER " + user); receive(in); send(out, "PASS " + pass); receive(in); } private int checkMyMail (BufferedReader in, BufferedWriter out) throws IOException { return GetNumberOfMessages(in, out); } public int GetNumberOfMessages (BufferedReader in, BufferedWriter out) throws IOException { int i = 0; String s; send(out, "LIST"); receive(in); while((s = receive(in)) != null) { if (!(s.equals("."))) { i++; } else return i; } return 0; } }
What are the necessary things that i need to do or changes to the above code in order to read the attachments correctly??
Some codings would really be helpfull
Thank You
Yours Sincerely
Richard West
Microsoft uses "One World, One Web, One Program" as a slogan.
Doesn’t that sound like "Ein Volk, Ein Reich, Ein Führer" to you, too?
— Eric S. Raymond
Tell me what type of software do you like and what would you pay for it
http://www.daniweb.com/techtalkforums/thread19660.html
Doesn’t that sound like "Ein Volk, Ein Reich, Ein Führer" to you, too?
— Eric S. Raymond
Tell me what type of software do you like and what would you pay for it
http://www.daniweb.com/techtalkforums/thread19660.html
![]() |
Similar Threads
- bill gates is evil (IT Professionals' Lounge)
- Criss Angel (Geeks' Lounge)
- hi all! (Legacy and Other Languages)
- new hard drive installed - RAM failure (Storage)
- 7 Ways to Ensure Your E-mail Gets Read (Windows NT / 2000 / XP)
- total tech virgin seeks geeks help (IT Professionals' Lounge)
- I need help on my 'address book' assignment! (C++)
Other Threads in the Java Forum
- Previous Thread: scrollbar applet
- Next Thread: Connecting to Oracle through Blackberry Handheld Device
| Thread Tools | Search this Thread |
-xlint add android api applet application applications array arrays automation bank bi binary blackberry bluetooth chat class client code compile compiler component database development digit eclipse equation error event fractal freeze functiontesting game gameprogramming givemetehcodez graphics gui health html hyper ide idea image infinite input int integer j2me java javame javaprojects jetbrains jni jpanel jtable julia learningresources linux list login loop main map method methods mobile myregfun netbeans newbie nonstatic notdisplaying pearl problem program programming project qt recursion scanner screen scrollbar server set sms sort sorting spamblocker sql sqlserver string superclass swing system text-file thread threads tree variablebinding windows xor





