getPartWithContentId method

MimePart? getPartWithContentId(
  1. String cid
)

Retrieves the part with the specified Content-ID cid.

Implementation

MimePart? getPartWithContentId(String cid) {
  if (!cid.startsWith('<')) {
    cid = '<$cid>';
  }
  cid = cid.toLowerCase();
  final allParts = allPartsFlat;
  for (final part in allParts) {
    final partCid = part._getLowerCaseHeaderValue('content-id');
    if (partCid != null && partCid.toLowerCase() == cid) {
      return part;
    }
  }
  if (body != null) {
    final bodyPart = body!.findFirstWithContentId(cid);
    if (bodyPart != null) {
      return getPart(bodyPart.fetchId!);
    }
  }
  return null;
}