jodd-mail/src/main/java/jodd/mail/SendMailSession.java
private void addBodyData(final Email emailWithData, final MimeMessage msgToSet) throws MessagingException {
		final List<EmailMessage> messages = emailWithData.messages();

		final int totalMessages = messages.size();

		// Need to use new list since filterEmbeddedAttachments(List) removes attachments from the source List
		final List<EmailAttachment<? extends DataSource>> attachments = new ArrayList<>(emailWithData.attachments());

		if (attachments.isEmpty() && totalMessages == 1) {
			// special case: no attachments and just one content
			setContent(messages.get(0), msgToSet);

		} else {
			final MimeMultipart multipart = new MimeMultipart();

			final MimeMultipart msgMultipart = new MimeMultipart(ALTERNATIVE);
			multipart.addBodyPart(getBaseBodyPart(msgMultipart));
			for (final EmailMessage emailMessage : messages) {
				msgMultipart.addBodyPart(getBodyPart(emailMessage, attachments));
			}

			addAnyAttachments(attachments, multipart);

			msgToSet.setContent(multipart);
		}
	}
private void addBodyData(final Email emailWithData, final MimeMessage msgToSet) throws MessagingException {
		final List<EmailMessage> messages = emailWithData.messages();

		final int totalMessages = messages.size();

		// Need to use new list since filterEmbeddedAttachments(List) removes attachments from the source List
		final List<EmailAttachment<? extends DataSource>> attachments = new ArrayList<>(emailWithData.attachments());

		if (attachments.isEmpty() && totalMessages == 1) {
			// special case: no attachments and just one content
			setContent(messages.get(0), msgToSet);

		} else {
			final MimeMultipart multipart = new MimeMultipart();

			final MimeMultipart msgMultipart = new MimeMultipart(ALTERNATIVE);
			multipart.addBodyPart(getBaseBodyPart(msgMultipart));
			for (final EmailMessage emailMessage : messages) {
				msgMultipart.addBodyPart(getBodyPart(emailMessage, attachments));
			}

			addAnyAttachments(attachments, multipart);

			msgToSet.setContent(multipart);
		}
	}
private void addBodyData ( final Email emailWithData , final MimeMessage msgToSet ) throws MessagingException { final List < EmailMessage > messages = emailWithData . messages ( ) ; final int totalMessages = messages . size ( ) ; // Need to use new list since filterEmbeddedAttachments(List) removes attachments from the source List final List < EmailAttachment < ? extends DataSource > > attachments = new ArrayList <> ( emailWithData . attachments ( ) ) ; if ( attachments . isEmpty ( ) && totalMessages == 1 ) { // special case: no attachments and just one content setContent ( messages . get ( 0 ) , msgToSet ) ; } else { final MimeMultipart multipart = new MimeMultipart ( ) ; final MimeMultipart msgMultipart = new MimeMultipart ( ALTERNATIVE ) ; multipart . addBodyPart ( getBaseBodyPart ( msgMultipart ) ) ; for ( final EmailMessage emailMessage : messages ) { msgMultipart . addBodyPart ( getBodyPart ( emailMessage , attachments ) ) ; } addAnyAttachments ( attachments , multipart ) ; msgToSet . setContent ( multipart ) ; } }
Adds message data and attachments.

@param emailWithData {@link Email} with data
@param msgToSet      {@link MimeMessage} to set data into.
@throws MessagingException if there is a failure.
Adds message data and attachments .