// no multipart handling?
if( !container.isMultipartEnabled() )
{
for( int c = 0; c < attachments.size(); c++ )
{
Attachment att = attachments.get( c );
if( att.getAttachmentType() != Attachment.AttachmentType.CONTENT )
{
addSingleAttachment( mp, contentIds, att );
}
}
}
else
{
// first identify if any part has more than one attachments
Map<String, List<Attachment>> attachmentsMap = new HashMap<String, List<Attachment>>();
for( int c = 0; c < attachments.size(); c++ )
{
Attachment att = attachments.get( c );
if( att.getAttachmentType() == Attachment.AttachmentType.CONTENT )
continue;
String partName = att.getPart();
if( !attachmentsMap.containsKey( partName ) )
{
attachmentsMap.put( partName, new ArrayList<Attachment>() );
}
attachmentsMap.get( partName ).add( att );
}
// add attachments
for( Iterator<String> i = attachmentsMap.keySet().iterator(); i.hasNext(); )
{
attachments = attachmentsMap.get( i.next() );
if( attachments.size() == 1 )
{
Attachment att = attachments.get( 0 );
addSingleAttachment( mp, contentIds, att );
}
// more than one attachment with the same part -> create multipart
// attachment
else if( attachments.size() > 1 )