bbottema / outlook-message-parser

A Java parser for Outlook messages (.msg files)
76 stars 35 forks source link

Creator/Modifier of msg file is interfering the identification of the sender email address #77

Open sanastasiadis opened 5 months ago

sanastasiadis commented 5 months ago

In OutlookMessage, in the method setProperty, all the following properties are considered to identify the sender email address, leading to setFromEmail:

(According to: fileformat.info, exchange server protocol)

I think that 0x3ffa property has to be excluded from this check, as the sender is not the same person as the creator/modifier of the msg file.

On top of this, even if the message contains all the above 3 properties, if one of them includes a value in X500 data, it will not be taken into consideration, as setFromEmail forces the value set to always contain "@".

bbottema commented 5 months ago

We have a regex somewhere that detects x500 address and since very recently we have a separate field for x500 address in Recipient (see https://github.com/bbottema/outlook-message-parser/issues/73 and https://github.com/bbottema/outlook-message-parser/pull/75). Perhaps we should have that check here as well, so we don't overwrite an email address if it is present.

sanastasiadis commented 5 months ago

I agree, it's good to have the regex check.

However, in my PR I still use the "force" flag so the occasional normal email address does not get overwritten. The fromEmail will be updated:

OR

if (force || this.fromEmail == null) {
    this.fromEmail = fromEmail;
}