Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > How to get the sender's address when getFrom returns null in javamail?

Reply
Thread Tools

How to get the sender's address when getFrom returns null in javamail?

 
 
news
Guest
Posts: n/a
 
      10-24-2003
Hi Gary,

If I use the following printMessage method:

public static void printMessage(Message message)
{
try
{
for (Enumeration e = message.getAllHeaders();
e.hasMoreElements(); ){
System.out.println("Headers: "+ e.nextElement());}

if (message.getAllHeaders() != null)
System.out.println("Got headers for the received emails"+
message.getHeader("Content-Type"));
// -- Get the message part (i.e. the message itself) --
Part messagePart=message;
Object content=messagePart.getContent();

// -- or its first body part if it is a multipart message --
if (content instanceof Multipart)
{
messagePart=((Multipart)content).getBodyPart(0);
System.out.println("I got a Multipart Message!");
}
}

With deug off, output is
Got headers for the received emails null
With debug on, the output is

DEBUG: JavaMail version 1.3.1ea
DEBUG: java.io.FileNotFoundException:
C:\JBuilder9\jdk1.4\jre\lib\javamail.providers (The system cannot find the
file specified)
DEBUG: !anyLoaded
DEBUG: not loading resource: /META-INF/javamail.providers
DEBUG: successfully loaded resource: /META-INF/javamail.default.providers
DEBUG: Tables of loaded providers
DEBUG: Providers Listed By Class Name:
{com.sun.mail.smtp.SMTPTransport=javax.mail.Provid er[TRANSPORT,smtp,com.sun.
mail.smtp.SMTPTransport,Sun Microsystems, Inc],
com.sun.mail.imap.IMAPStore=javax.mail.Provider[STORE,imap,com.sun.mail.imap
..IMAPStore,Sun Microsystems, Inc],
com.sun.mail.pop3.POP3Store=javax.mail.Provider[STORE,pop3,com.sun.mail.pop3
..POP3Store,Sun Microsystems, Inc]}
DEBUG: Providers Listed By Protocol:
{imap=javax.mail.Provider[STORE,imap,com.sun.mail.imap.IMAPStore,Sun
Microsystems, Inc],
pop3=javax.mail.Provider[STORE,pop3,com.sun.mail.pop3.POP3Store,Sun
Microsystems, Inc],
smtp=javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Sun
Microsystems, Inc]}
DEBUG: successfully loaded resource: /META-INF/javamail.default.address.map
DEBUG: !anyLoaded
DEBUG: not loading resource: /META-INF/javamail.address.map
DEBUG: java.io.FileNotFoundException:
C:\JBuilder9\jdk1.4\jre\lib\javamail.address.map (The system cannot find the
file specified)
DEBUG: getProvider() returning
javax.mail.Provider[STORE,pop3,com.sun.mail.pop3.POP3Store,Sun Microsystems,
Inc]
DEBUG POP3: connecting to host "mailsrv11-pop3.siteserver.net", port 110
S: +OK POP3 server ready <11186512.1514841515@mailsrv11>
C: USER http://www.velocityreviews.com/forums/(E-Mail Removed)
S: +OK Please send PASS
C: PASS ***********
S: +OK User mailbox has 1 message (1361 octets)
C: STAT
S: +OK 1 1361
Got headers for the received emailsnull
C: RETR 1
S: +OK
Received: from [24.192.49.141] by mailsrv11.siteserver.net [63.203.180.102]
with SmartMax MailMax for (E-Mail Removed); Fri, 24 Oct 2003
10:06:55 -0700
Return-Path: <(E-Mail Removed)>
Message-ID: <009801c39a6b$27a419f0$cf00a8c0@wg014>
From: "Qiang Zhao" <(E-Mail Removed)>
To: "Qiang Zhao" <(E-Mail Removed)>
Subject: I am glad
Date: Fri, 24 Oct 2003 13:12:30 -0700
MIME-Version: 1.0
Content-Type: multipart/alternative;
boundary="----=_NextPart_000_0095_01C39A30.7A9727A0"
X-Priority: 3
X-MSMail-Priority: Normal
X-Mailer: Microsoft Outlook Express 5.50.4807.1700
X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300
This is a multi-part message in MIME format.
------=_NextPart_000_0095_01C39A30.7A9727A0
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
------=_NextPart_000_0095_01C39A30.7A9727A0
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META content=3D"text/html; charset=3Diso-8859-1" =
http-equiv=3DContent-Type>
<META content=3D"MSHTML 5.00.3502.5390" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV>&nbsp;</DIV></BODY></HTML>
------=_NextPart_000_0095_01C39A30.7A9727A0--
C: QUIT
S: +OK

It seems that from field appeared in the deug mode. How do you think?

Thank you very much, Gary.



 
Reply With Quote
 
 
 
 
GaryM
Guest
Posts: n/a
 
      10-24-2003
"news" <(E-Mail Removed)> wrote in
news:Ujcmb.24696$(E-Mail Removed) ble.rogers.com:

> Hi Gary,
>
> I am really appreciate your kindness. Here are the output after
> the debug is set on:


Weird. I am not seeing a corresponding POP3 command for the
gettAllHeaders() method. The STAT corresponds to the getMessages()
(count and mailbox size). JavaMail would issued, for example, a "TOP
1 15" command after that.

I just checked the javamail source and all POP3 commands are sent to
the debug outstream BEFORE they are sent to the server. So obviously
something is happening before the command gets that far.

I am not sure where to go next though. Could there be character set
issues here?

Gary
 
Reply With Quote
 
 
 
 
GaryM
Guest
Posts: n/a
 
      10-24-2003
"news" <(E-Mail Removed)> wrote in news:78dmb.26136$3f.21432
@twister01.bloor.is.net.cable.rogers.com:

>
> It seems that from field appeared in the deug mode. How do you think?
>
> Thank you very much, Gary.


I just sent a reply to you before I saw this.

This confirms to me there is an issue specific to the retrieving of
headers. the POP3 Command "RETR 1" simply orders the server to retrieve
all of the message in response to the getContent() method. So the fact
that the headers are part of this is not surprising.

However, all commands related to the retrieving of headers are failing.
Do you have a non standard character set on your machine?
 
Reply With Quote
 
news
Guest
Posts: n/a
 
      10-24-2003
How to check if I have a non statndard character set in the machine? Sorry
to trouble you with so simple question. But I really don't know. Is that a
issue to the problem? Thanks.
"GaryM" <(E-Mail Removed)> wrote in message
news:Xns941E8C40D87ECR3344324357788499939@216.168. 3.44...
> "news" <(E-Mail Removed)> wrote in news:78dmb.26136$3f.21432
> @twister01.bloor.is.net.cable.rogers.com:
>
> >
> > It seems that from field appeared in the deug mode. How do you think?
> >
> > Thank you very much, Gary.

>
> I just sent a reply to you before I saw this.
>
> This confirms to me there is an issue specific to the retrieving of
> headers. the POP3 Command "RETR 1" simply orders the server to retrieve
> all of the message in response to the getContent() method. So the fact
> that the headers are part of this is not surprising.
>
> However, all commands related to the retrieving of headers are failing.
> Do you have a non standard character set on your machine?



 
Reply With Quote
 
GaryM
Guest
Posts: n/a
 
      10-24-2003
"news" <(E-Mail Removed)> wrote in
news:7Jdmb.27388$(E-Mail Removed) able.rogers.com:

> How to check if I have a non statndard character set in the
> machine? Sorry to trouble you with so simple question. But I
> really don't know. Is that a issue to the problem? Thanks.


You know I am just guessing and I don't want to waste your time. I
think it is best to write to someone on the Javamail team at this
point. I am fairly sure you are doing everything right. Try writing
to (E-Mail Removed).

Check here for the protocol on how to submit bugs.

http://java.sun.com/products/javamail/NOTES.txt

I would definitely include the code and the debug output for the
version where you are doing the getAllHeaders(). This should make it
clear to the reader that Javamail is not working somewhere outside
your code.

I am very sorry I can't help you more with this. Please post back if
you find a solution.

Gary
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
createImage sometime returns null and sometime returns non-null. vizlab Java 3 10-17-2007 11:21 AM
Map.get(key) returns null after inserting key Mize-ze Java 4 01-01-2007 04:31 PM
Begin() applied on empty Vector returns NULL or non null value???? Col C++ 1 04-21-2006 01:12 PM
"stringObj == null" vs "stringObj.equals(null)", for null check?? qazmlp1209@rediffmail.com Java 5 03-29-2006 10:37 PM
Can't get DataSource of a repeater, returns null Alan Silver ASP .Net 2 07-12-2005 01:57 PM



Advertisments