473,395 Members | 1,526 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Java Mail: Is There A Simple Way to Get ALL Message Headers

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 = Session.getDefaultInstance(props, null);
try {
oStore = oSession.getStore("pop3");
oStore.connect(sInServer, sInName, sInPass);
oFolder = oStore.getFolder("INBOX");
oFolder.open(Folder.READ_WRITE);
oMessage = oFolder.getMessages();
if (oMessage.length == 0) {return;}}
} catch (Exception e)
{System.out.println("Problem with opening and getting messages: " + e);}
for (int i=0, n = oMessage.length; i < n; i++) {
try {
System.out.println(i + ": " + oMessage[i].getFrom()[0] + "\t"
+oMessage[i].getSubject());
} catch (Exception e)
{System.out.println("Problem printing message info: " + e);}
try {sContent = (String) oMessage[i].getContent();} catch (Exception e)
{System.out.println("Problem getting message content: " + e);}
//From here, do stuff with the message -- like saving the content
}

The code is still new, so I'll be using actual error handlers.

Here's the problem: There are times when I want to save a copy of the ENTIRE
message, including the headers, so I can use the headers later (possible
spam filtering and other stuff).

I've found the getHeader() and similar functions in Java Mail that return
headers as objects. Isn't there some SIMPLE and quick way to get a string
that contains all the headers? Like a "Header" version of getContent()?

I basically just want to dump the header and content to the drive. I
thought I read somewhere that there was a call to use to get the full
header and content together, but I haven't been able to re-locate it or
verify it's what I read.

Thanks for any help!

Hal
Jul 17 '05 #1
0 2191

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: pee2pee | last post by:
Hi, I have below code: <html> <head> <title>Contacting Worldpay, Please wait.......</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> </head> <body...
0
by: James Hong | last post by:
Help please, I try to sending an email from my html page using the java applet. but it give error on most of the PC only very few work, what is the error i make the java applet show as below ...
1
by: Nick Chorley | last post by:
Lo all, I've written a simple program that connects to a POP3 server, allows me to authenticate and then retrieves a certain message. The problem I'm having is that when it retrives the message...
8
by: baustin75 | last post by:
Posted: Mon Oct 03, 2005 1:41 pm Post subject: cannot mail() in ie only when debugging in php designer 2005 -------------------------------------------------------------------------------- ...
3
by: Sai Kit Tong | last post by:
I posted for help on legacy code interface 2 days ago. Probably I didn't make it clear in my original mail. I got a couple of answers but none of them address my issues directly (See attached...
1
by: David Van D | last post by:
Hi there, A few weeks until I begin my journey towards a degree in Computer Science at Canterbury University in New Zealand, Anyway the course tutors are going to be teaching us JAVA wth bluej...
12
by: e_matthes | last post by:
Hello everyone, I am trying to use the mail() function to send a simple, text-only message. I have two websites hosted by the same company, on different servers. One is old and established,...
10
by: crazycooter | last post by:
I found an old thread on this (http://groups.google.com/group/alt.php/ browse_thread/thread/751edb9c723316c4/ea9bf92a9c6b807c?lnk=gst&q=mail() +duplicate&rnum=7#ea9bf92a9c6b807c), but there didnt...
5
by: Gordon | last post by:
I'm working on a reset password script for my CMS, that will generate a random password and email it to a user when they request one. The problem I am having is that the mails being sent out are...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
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
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...

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.