c# - MimeKit: How to embed images? -
i using mailkit/mimekit 1.2.7 (latest nuget version).
i tried embed image in html body of email following sample api documentation (section "using bodybuilder").
my current code looks this:
var builder = new bodybuilder(); builder.htmlbody = @"<p>hey!</p><img src=""image.png"">"; var pathimage = path.combine(misc.getpathofexecutingassembly(), "image.png"); builder.linkedresources.add(pathlogofile); message.body = builder.tomessagebody();
i can send email , in fact image is attached email. not embedded.
am missing something? or apple mail's fault (this email client using receiving emails)?
i grateful idea (and jeffrey stedfast providing such great toolset!!).
ingmar
try bit more this:
var builder = new bodybuilder (); var pathimage = path.combine (misc.getpathofexecutingassembly (), "image.png"); var image = builder.linkedresources.add (pathlogofile); image.contentid = mimeutils.generatemessageid (); builder.htmlbody = string.format (@"<p>hey!</p><img src=""cid:{0}"">", image.contentid); message.body = builder.tomessagebody ();
if works you, i'll update documentation.
the problem might apple's multipart/related
implementation not resolve image.png
reference using content-location
header on image mime part (possibly because relative url).
the cid:
url-type should work, though, it's bit more awkward construct since need know content-id
values each image attachment.
Comments
Post a Comment