Repeated in 8.8.3. outlookMsgToEmail() duplicates To and Cc addresses, seemingly depending on the "name" used for the recipient addresses matching.
Pass:
To Andrew McQuillen andrew.mcquillen@example.com
Cc test@example.com test@example.com
[Recipient{name='Andrew McQuillen', address='andrew.mcquillen@example.com', type=To}, Recipient{name='test@example.com', address='test@example.com', type=Cc}]
Fail:
To Andrew McQuillen andrew.mcquillen@example.com
Cc Andrew McQuillen dummy@gmail.com
[Recipient{name='Andrew McQuillen', address='andrew.mcquillen@example.com', type=To}, Recipient{name='Andrew McQuillen', address='dummy@gmail.com', type=To}, Recipient{name='Andrew McQuillen', address='andrew.mcquillen@example.com', type=Cc}, Recipient{name='Andrew McQuillen', address='dummy@gmail.com', type=Cc}]
Code to repeat using attached examples:
@Test
void givenMsgFile_avoidDuplicateCc() {
try {
Email t_message = EmailConverter.outlookMsgToEmail(new File("TestingCC.msg"));
assertTrue(countCcRecipients(t_message.getRecipients()) == 1);
String t_eml = EmailConverter.emailToEML(t_message);
Email t_message2 = EmailConverter.emlToEmail(new ByteArrayInputStream(t_eml.getBytes()));
assertTrue(countCcRecipients(t_message2.getRecipients()) == 1);
} catch (Exception e) {
e.printStackTrace();
}
}
@Test
void givenMsgFileSameName_avoidDuplicateCc() {
try {
Email t_message = EmailConverter.outlookMsgToEmail(new File("TestingCCSameName.msg"));
assertTrue(countCcRecipients(t_message.getRecipients()) == 1);
String t_eml = EmailConverter.emailToEML(t_message);
Email t_message2 = EmailConverter.emlToEmail(new ByteArrayInputStream(t_eml.getBytes()));
assertTrue(countCcRecipients(t_message2.getRecipients()) == 1);
} catch (Exception e) {
e.printStackTrace();
}
}
public static int countCcRecipients(List<Recipient> recipients) {
int ccCount = 0;
for (Recipient recipient : recipients) {
if ("Cc".equals(recipient.getType().toString())) {
ccCount++;
}
}
return ccCount;
}
TestingMsg.zip
Repeated in 8.8.3. outlookMsgToEmail() duplicates To and Cc addresses, seemingly depending on the "name" used for the recipient addresses matching.
Pass:
To Andrew McQuillen andrew.mcquillen@example.com
Cc test@example.com test@example.com
[Recipient{name='Andrew McQuillen', address='andrew.mcquillen@example.com', type=To}, Recipient{name='test@example.com', address='test@example.com', type=Cc}]
Fail:
To Andrew McQuillen andrew.mcquillen@example.com
Cc Andrew McQuillen dummy@gmail.com
[Recipient{name='Andrew McQuillen', address='andrew.mcquillen@example.com', type=To}, Recipient{name='Andrew McQuillen', address='dummy@gmail.com', type=To}, Recipient{name='Andrew McQuillen', address='andrew.mcquillen@example.com', type=Cc}, Recipient{name='Andrew McQuillen', address='dummy@gmail.com', type=Cc}]
Code to repeat using attached examples:
TestingMsg.zip