You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Enhancement: Process all Outlook message headers, either copying the as-is or translating them to respective Simple Java Mail API calls #407
When using the EmailConverter.outlookMsgToEmail method, the headers are missing in the Email object returned. Below is a sample which shows the headers are retrieved when using OutlookMessageParser's parseMsg however using the same input file with EmailConverter shows no headers are retrieved.
package com.test;
import java.io.File;
import java.io.IOException;
import org.simplejavamail.api.email.Email;
import org.simplejavamail.converter.EmailConverter;
import org.simplejavamail.outlookmessageparser.OutlookMessageParser;
public class TestEmailHeaders {
public static void main(String[] args) {
OutlookMessageParser msgp = new OutlookMessageParser();
org.simplejavamail.outlookmessageparser.model.OutlookMessage msg;
String inputFileName = "YourEmailFile.msg"; // <--- Update this with the name of an Outlook email file (.msg) on your system.
try {
msg = msgp.parseMsg(inputFileName);
System.out.println(">>> Headers from msg: " + msg.getHeaders());
Email email = EmailConverter.outlookMsgToEmail(new File(inputFileName));
System.out.println(">>> Headers from email: " + email.getHeaders());
} catch (IOException e) {
// This should never occur during this test.
e.printStackTrace();
}
}
}
In the output from the above, you will notice that the ">>> Headers from msg:" is followed by a number of headers but the ">>> Headers from email: {}" indicates that there are no headers returned from the Email's getHeaders() method.
The problem may stem from the buildEmailFromOutlookMessage method in org/simplejavamail/internal/outlooksupport/converter/OutlookEmailConverter which does not appear to copy the headers from the OutlookMessage to the Email object after converting them from a string.
So as I started adding the proper headers to both outlook-message-parser and mapping the to Email objects, I realized they should be processed exactly the same way as headers from MimeMessage are. Which is that some headers should not be copied as-is, but translated to the Simple Java Mail version of it. Examples of this are dispositionNotificationTo, bounceToRecipient and some others.
On top of that I ran into CRLF injection detection issues due to headers coming back differently from Outlook and MimeMessages (having to do with MimeUtility.encoding/folding).
It was quite a challenge to get everything working finally, but I think I nailed it now. Going to release soon.
changed the title [-]Headers are missing in Email object when using EmailConverter.outlookMsgToEmail[/-][+]Enhancement: Process all Outlook message headers, either copying the as-is or translating them to respective Simple Java Mail API calls[/+]on Jul 19, 2022
Activity
bbottema commentedon Jul 18, 2022
Correct you are... hmm, I wonder why I left it out.
#407: process Outlook message headers, just like with MimeMessages
#407: process Outlook message headers, just like with MimeMessages
bbottema commentedon Jul 19, 2022
So as I started adding the proper headers to both outlook-message-parser and mapping the to Email objects, I realized they should be processed exactly the same way as headers from MimeMessage are. Which is that some headers should not be copied as-is, but translated to the Simple Java Mail version of it. Examples of this are dispositionNotificationTo, bounceToRecipient and some others.
On top of that I ran into CRLF injection detection issues due to headers coming back differently from Outlook and MimeMessages (having to do with MimeUtility.encoding/folding).
It was quite a challenge to get everything working finally, but I think I nailed it now. Going to release soon.
[-]Headers are missing in Email object when using EmailConverter.outlookMsgToEmail[/-][+]Enhancement: Process all Outlook message headers, either copying the as-is or translating them to respective Simple Java Mail API calls[/+]bbottema commentedon Jul 19, 2022
Released in 7.4.0