String rootId = ctImpl.getRootId();
boolean hasAttachments = (boundary != null);
Codec rootCodec = getMimeRootCodec(packet);
if (hasAttachments) {
writeln("--"+boundary, out);
ContentType ct = rootCodec.getStaticContentType(packet);
String ctStr = (ct != null) ? ct.getContentType() : rootCodec.getMimeType();
if (rootId != null) writeln("Content-ID: " + rootId, out);
writeln("Content-Type: " + ctStr, out);
writeln(out);
}
ContentType primaryCt = rootCodec.encode(packet, out);
if (hasAttachments) {
writeln(out);
// Encode all the attchments
for (Attachment att : msg.getAttachments()) {