[ 
https://issues.apache.org/jira/browse/IMAP-257?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12995544#comment-12995544
 ] 

Jeff Huff commented on IMAP-257:
--------------------------------

Ok, it is dropping the first header.  If I add one statement, setSentDate(new 
Date()), the From address is saved to the appended message, BUT the Date is 
missing.

So this code appends a message with the From, but looses the Date: header 
because it is the first one.

            InternetAddress addr = new InternetAddress ("jhuff@localhost", 
"Jeff Huff");
            Message message = new MimeMessage(session);
            message.setFrom (addr);
            ((MimeMessage)message).setSentDate (new Date());
            message.setFlag (Flags.Flag.DRAFT, true);
            MimeBodyPart textPart = new MimeBodyPart();
            textPart.setText ("test");
            Multipart mp = new MimeMultipart();
            mp.addBodyPart (textPart);
            message.setContent (mp);
            message.saveChanges ();
            messageUID = drafts.getUIDNext ();
            drafts.appendMessages (new Message[] { message });
 

DEBUG: JavaMail version 1.4.4
DEBUG: successfully loaded resource: /META-INF/javamail.default.providers
DEBUG: Tables of loaded providers
DEBUG: Providers Listed By Class Name: 
{com.sun.mail.smtp.SMTPSSLTransport=javax.mail.Provider[TRANSPORT,smtps,com.sun.mail.smtp.SMTPSSLTransport,Sun
 Microsystems, Inc], 
com.sun.mail.smtp.SMTPTransport=javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Sun
 Microsystems, Inc], 
com.sun.mail.imap.IMAPSSLStore=javax.mail.Provider[STORE,imaps,com.sun.mail.imap.IMAPSSLStore,Sun
 Microsystems, Inc], 
com.sun.mail.pop3.POP3SSLStore=javax.mail.Provider[STORE,pop3s,com.sun.mail.pop3.POP3SSLStore,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: 
{imaps=javax.mail.Provider[STORE,imaps,com.sun.mail.imap.IMAPSSLStore,Sun 
Microsystems, Inc], 
imap=javax.mail.Provider[STORE,imap,com.sun.mail.imap.IMAPStore,Sun 
Microsystems, Inc], 
smtps=javax.mail.Provider[TRANSPORT,smtps,com.sun.mail.smtp.SMTPSSLTransport,Sun
 Microsystems, Inc], 
pop3=javax.mail.Provider[STORE,pop3,com.sun.mail.pop3.POP3Store,Sun 
Microsystems, Inc], 
pop3s=javax.mail.Provider[STORE,pop3s,com.sun.mail.pop3.POP3SSLStore,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: getProvider() returning 
javax.mail.Provider[STORE,imap,com.sun.mail.imap.IMAPStore,Sun Microsystems, 
Inc]
DEBUG: mail.imap.fetchsize: 16384
DEBUG: mail.imap.statuscachetimeout: 1000
DEBUG: mail.imap.appendbuffersize: -1
DEBUG: mail.imap.minidletime: 10
DEBUG: trying to connect to host "localhost", port 143, isSSL false
* OK JAMES IMAP4rev1 Server  Server 169.254.53.191 is ready.
A0 CAPABILITY
* CAPABILITY IMAP4rev1 LITERAL+ CHILDREN IDLE NAMESPACE UIDPLUS UNSELECT
A0 OK CAPABILITY completed.
DEBUG: protocolConnect login, host=localhost, user=jhuff@localhost, 
password=<non-null>
A1 LOGIN jhuff@localhost carefx
A1 OK LOGIN completed.
A2 CAPABILITY
* CAPABILITY IMAP4rev1 LITERAL+ CHILDREN IDLE NAMESPACE UIDPLUS UNSELECT
A2 OK CAPABILITY completed.
A3 LIST "" Drafts
* LIST (\HasNoChildren) "." "Drafts"
A3 OK LIST completed.
DEBUG: connection available -- size: 1
A4 SELECT Drafts
* FLAGS (\Answered \Deleted \Draft \Flagged \Seen)
* 1 EXISTS
* 0 RECENT
* OK [UIDVALIDITY 1265750761]
* OK [PERMANENTFLAGS (\Answered \Deleted \Draft \Flagged \Seen)]
* OK [UIDNEXT 11]
A4 OK [READ-WRITE] SELECT completed.
A5 FETCH 1 (UID)
* 1 FETCH (UID 10)
A5 OK FETCH completed.
UID=10
A6 APPEND Drafts (\Draft) "16-Feb-2011 15:11:52 -0700" {420+}
Date: Wed, 16 Feb 2011 15:11:52 -0700 (MST)
From: Jeff Huff <jhuff@localhost>
Message-ID: <933725891.1.1297894312931.JavaMail.jhuff@localhost>
MIME-Version: 1.0
Content-Type: multipart/mixed; 
        boundary="----=_Part_0_1494824825.1297894312910"

------=_Part_0_1494824825.1297894312910
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

test
------=_Part_0_1494824825.1297894312910--

* 2 EXISTS
* 1 RECENT
A6 OK [APPENDUID 1265750761 11] APPEND completed.
MessageUID=11
A7 CLOSE
A7 OK CLOSE completed.
DEBUG: added an Authenticated connection -- size: 1
DEBUG: connection available -- size: 1
A8 SELECT Drafts
* FLAGS (\Answered \Deleted \Draft \Flagged \Seen)
* 1 EXISTS
* 0 RECENT
* OK [UIDVALIDITY 1265750761]
* OK [UNSEEN 1]
* OK [PERMANENTFLAGS (\Answered \Deleted \Draft \Flagged \Seen)]
* OK [UIDNEXT 12]
A8 OK [READ-WRITE] SELECT completed.
A9 UID FETCH 11 (UID)
* 1 FETCH (UID 11)
A9 OK FETCH completed.
com.sun.mail.imap.IMAPMessage@6791d8c1
A10 CLOSE
A10 OK CLOSE completed.
DEBUG: added an Authenticated connection -- size: 1
A11 LOGOUT
* BYE IMAP4rev1 Server logging out
A11 OK LOGOUT completed.
DEBUG: IMAPStore connection dead
DEBUG: IMAPStore cleanup, force false
DEBUG: IMAPStore cleanup done


And the actual message appended...

From: Jeff Huff <jhuff@localhost>
Message-ID: <933725891.1.1297894312931.JavaMail.jhuff@localhost>
MIME-Version: 1.0
Content-Type: multipart/mixed; 
        boundary="----=_Part_0_1494824825.1297894312910"

------=_Part_0_1494824825.1297894312910
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

test
------=_Part_0_1494824825.1297894312910--

Notice the first field from the mail.debug shows that a Date: header was there, 
but it did not make it into the appended message.


> appendMessages(Message[]) does not save the from address
> --------------------------------------------------------
>
>                 Key: IMAP-257
>                 URL: https://issues.apache.org/jira/browse/IMAP-257
>             Project: JAMES Imap
>          Issue Type: Bug
>            Reporter: Jeff Huff
>
> Creating a new empty message in a Drafts folder stopped saving the from 
> address when calling appendMessages(Message[]).
>             InternetAddress addr = new InternetAddress ("jhuff@localhost", 
> "Jeff Huff");
>             Message message = new MimeMessage(session);
>             message.setFrom (addr);
>             message.setFlag (Flags.Flag.DRAFT, true);
>             message.setText ("");
>             message.saveChanges ();
>             messageUID = drafts.getUIDNext ();
>             drafts.appendMessages (new Message[] { message });
>             System.out.println("MessageUID=" + messageUID);
> Yet if you add a call to setSentDate(new Date()); on a MimeMessage right 
> after setFrom, it will set the From address.  I have tried calling other 
> methods to get it to refresh the headers, but nothing else seems to cause the 
> from address to stick when added to the folder.
> This was working in M2.

-- 
This message is automatically generated by JIRA.
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to