Regarding receiving a mail !!
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   revanth_reddy
Posted On:   Friday, March 23, 2007 01:08 AM

Hello everybody Im having a problem receving a mail i.e whenever i open my inbox i get a different message value . com.sun.mail.pop3.POP3Message@146b6db so whenever i refresh my page the number is getting changed. But when i run my receivemail.java without any use of servlets this code is executed successfully and the number is also same . Below is code of my servlet !!! import java.io.*; import javax.servlet.*; import javax.servlet.http.*; import java.util.Date; import javax.mail.Address; import javax.mail.Folder; import javax.mail.Message; import javax.mail.Session; import javax.mail.Store;    More>>


Hello everybody
Im having a problem receving a mail i.e whenever i open my inbox i get a different message value .

com.sun.mail.pop3.POP3Message@146b6db



so whenever i refresh my page the number is getting changed.
But when i run my receivemail.java without any use of servlets this code is executed successfully
and the number is also same .
Below is code of my servlet !!!


			

import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.util.Date;
import javax.mail.Address;
import javax.mail.Folder;
import javax.mail.Message;
import javax.mail.Session;
import javax.mail.Store;
import javax.mail.internet.MimeMessage;
import javax.mail.internet.InternetAddress;


public class Recievemail extends javax.servlet.http.HttpServlet
{
public void doPost(HttpServletRequest req, HttpServletResponse res) throws ServletException,IOException
{
res.setContentType("text/html");
PrintWriter out = res.getWriter();
try
{

HttpSession session=req.getSession(false);
String host = "pop.drdl.com";
String user = (String)session.getAttribute("user1");
String password = (String)session.getAttribute("password1");
Folder folder = null;
Store store = null;
String t;
// String mailer = "SimpleMsgSend - Test";
try
{
// Get a Session object
Session session3 = Session.getDefaultInstance(System.getProperties(), null);
// construct the message
store = session3.getStore("pop3");
store.connect(host, user, password);


// Open the Folder


folder = store.getDefaultFolder();
if (folder == null) {
out.println(" No default folder ");

}
folder = folder.getFolder("INBOX");
folder.open(Folder.READ_WRITE);
int totalMessages = folder.getMessageCount();


if (totalMessages == 0) {
out.println(" You have no messages ");
folder.close(false);
}

else {
out.println(" ");
out.println("You have " + totalMessages + " messages in ur inbox ");
out.println("Of which " + folder.getNewMessageCount() + " are new");
for(int k=1;k <=totalMessages;k++)
{
out.print("
");
int size;
Message m = folder.getMessage(k);
Address[] from = m.getFrom();
Address[] to = m.getRecipients(Message.RecipientType.TO);
Address[] cc = m.getRecipients(Message.RecipientType.CC);
Address[] bcc =m.getRecipients(Message.RecipientType.BCC);
String subject = m.getSubject();
size=m.getSize();
Object content = m.getContent();
out.println("Mail Message: "+k+"
");
out.println(m+"
");
out.println("
---------------
");
//out.println("
To: ");
int i = 0;
//for(i = 0; i < to.length; i++) out.print(to[i] + " ");
out.println("
From: ");
for(i = 0; i < from.length; i++)
out.println(from[i] + "
");
if (cc != null) {
out.print("
CC: ");
for(i = 0; i < cc.length; i++)
out.print(cc[i] + " ");
out.println(" ");
}
if (bcc != null)
{
out.print("
BCC: ");
for(i = 0; i < bcc.length; i++)
out.print(bcc[i] + " ");
}
out.println("SUBJECT :
"+subject);
out.println("SIZE:"+size);
out.println(" ");
t=String.valueOf(k);
out.println(" " );
out.println(" ");
// out.println(""+content);

}
out.println(" ");
}
folder.close(false);

} catch (Exception e)
{
out.println(" " + e + " ");
}



}


catch( Exception e)
{
out.println(" error occured"+e+" ");
}
}


}



CAN NEBDY PLZ HELP ME ON THIS AS SOON AS POSSIBLE

   <<Less

Re: Regarding receiving a mail !!

Posted By:   Christopher_Koenigsberg  
Posted On:   Sunday, March 25, 2007 11:15 AM

com.sun.mail.pop3.POP3Message@146b6db


That is just the mostly useless "toString" representation, of that object.

About | Sitemap | Contact