I came here to look for a solution, but I did not like the idea of finding "cid:" in all HTMLBody. Firstly, it slowly does this for each file name, and secondly, if "cid:" was present in the main text, I would get a false result. Also, doing ToLower () in HTMLBody is not a good idea.
HTMLBody, <img> . , "cid:" ( ).
Regex reg = new Regex(@"<img .+?>", RegexOptions.Singleline | RegexOptions.CultureInvariant | RegexOptions.IgnoreCase);
MatchCollection matches = reg.Matches(mailItem.HTMLBody);
foreach (string fileName in attachments.Select(a => a.FileName)
{
bool isMatch = matches
.OfType<Match>()
.Select(m => m.Value)
.Where(s => s.IndexOf("cid:" + fileName, StringComparison.InvariantCultureIgnoreCase) >= 0)
.Any();
Console.WriteLine(fileName + ": " + (isMatch ? "Inline" : "Attached"));
}
, , , , . , Regex, .