FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

outlookMsgToEmail duplicates recipients if same name used for To and Cc · Issue #504 · bbottema/simple-java-mail · GitHub

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

Description

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions


      Back | FazBrowse Home | New Git URL