473,508 Members | 2,515 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

problem in java mail

29 New Member
Hi;

i am trying to extract the sender address, subject and the content of the message in my webmail account;

i have successfully read the sender address and subject but i have problem with the getContent method IF the message is not purely a text message(an HTML post) it throw the java.lang.ClassCastException:javax.mail.internet.M imeMultipart

how can i solve this problem??

and this is the code ^_^

public class ReadE {

String host;

String from;

String password;

public ReadE(String h, String f, String p) {
host = h;
from = f;
password = p;

}

public void readEmail() throws Exception {

Properties props = new Properties();

Session session = Session.getDefaultInstance(props, null);

Store store = session.getStore("pop3");

store.connect(host, from, password);

Folder folder = store.getFolder("INBOX");

folder.open(Folder.READ_ONLY);

Message message[] = folder.getMessages();

String s = message[message.length - 1].getFrom()[0] + "";


System.out.println(message[message.length - 1].getFrom()[0]

+ "\n" + message[message.length - 2].getSubject() + "\n" +

(String) message[message.length - 2].getContent());//////////////here is the problem////////////////////////////////////////

// Close connection
folder.close(false);
store.close();

}
Mar 28 '07 #1
0 984

Sign in to post your reply or Sign up for a free account.

Similar topics

2
2441
by: S_p_ike | last post by:
Hi all, I have a problem with mail with attachments. To send e-mail with attachments from a form, I use Setec Astronomy's libmail class (v 1.4) (available here http://www.phpclasses.org/) ...
0
2196
by: Hal Vaughan | last post by:
I'm working with javax.mail.*. I have no problem with reading in messages. I'm not using multi-part messages or anything, I just use this setup: Session oSession =...
2
2971
by: vigupta12 | last post by:
Hi List, I am using java mail API. I have to embed an image with my html content. Here is the sample code that I am using for this. MimeMultipart multipart = new...
1
1281
dmjpro
by: dmjpro | last post by:
i am newbei in java mail program .... recently i came to know that without SMTP specification of a server i can't run the java mail program succcfully ..... is that true ..... if possible plz...
3
2195
dmjpro
by: dmjpro | last post by:
i have been trying to do mail programming in java.... al in vain one thing still irritating that SMTP ..... the server must have the SMTP service provider. how can i know that the server is...
3
1510
dmjpro
by: dmjpro | last post by:
i have JDK 1.2 and which version of JAVA-MAIL and JAF ll be compatible??? plz help. kind regards. dmjpro.
0
1263
jayam
by: jayam | last post by:
Hi I m developing a software for sending and receiving the mail using the java mail api . when i receive the mail the sender name will be display like this...
1
1414
by: sugard | last post by:
This time my task is to send a real message to the specified email address. The signatures for my method is void sendEmail (EmailAddress emailAddress, String message) I have gone through a...
1
6974
dmjpro
by: dmjpro | last post by:
I am using SMTP mail server. I am sending a mail from SMTP client using Java Mail. But now i am getting this exception... Relaying denied. IP name possibly forged The debug informations given...
2
8687
by: popprem | last post by:
Hi, I'm trying to send mail from our application using java mail api. There is a .css file which i need to use for it. How can i do it????? The problems i faced are : I tried to get the...
0
7133
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7336
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
7066
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7504
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5643
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5059
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4724
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3214
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1568
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.