Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

outlookMsgToEmail duplicates recipients if same name used for To and Cc #504

Open
atmcq opened this issue Apr 16, 2024 · 1 comment
Open
Labels
dependencies Pull requests that update a dependency file Priority-Low

Comments

@atmcq
Copy link

atmcq commented Apr 16, 2024

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

@bbottema
Copy link
Owner

Ok, I checked and this is actually a bug in outlook-message-parser. I added an issue there: bbottema/outlook-message-parser#76.

@bbottema bbottema added the dependencies Pull requests that update a dependency file label Apr 16, 2024
@bbottema bbottema reopened this Apr 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dependencies Pull requests that update a dependency file Priority-Low
Projects
None yet
Development

No branches or pull requests

2 participants