`multipart_related?` asks the question "is this @email multipart/related?", then we inline cid attachments without telling it which root part to work with. The inliner calls `multipart_parts` to find those parts, assuming that `@email.parts.select(&:multipart?).first.body.parts` are the part bodies affected. Then we return `multipart_parts`, assuming that the inliner munged them in-place.

```ruby
def parts
  @email.parts.map do |part|
    inline_multipart_related_cid_uris(part)
  end
end

def inline_multipart_related_cid_uris(root)
  if root.mime_type == 'multipart/related'
    find_multipart_related_start_part(root).tap do |start|
      embed_multipart_related_cids_as_data_uris(start, root.parts)
    end
  else
    root
  end
end

def find_multipart_related_start_part(root)
  if start_cid = part.content_type_parameters['start']
    root.parts.detect { |p| p.cid == start_cid }
  else
    root.parts.first
  end
end

def embed_multipart_related_cids_as_data_uris(start, parts)
  start.decoded.gsub(/cid:[^\s'"]+/) do |url|
    if referenced_part = parts.detect { |p| p.url == url }
      data_uri_for_part(referenced_part)
    else
      url
    end
  end
end

def data_uri_for_part(part)
  encoded = Base64.urlsafe_encode64(part.decoded)
  "data:#{part.mime_type};base64,#{encoded}"
end
```