I'm using MailKit to send emails in a C# ASP.NET MVC Framework 4.8 app. HTML emails to desktop Outlook show inline images fine. However, when sent to Gmail web, the inline images are attached to the message and show the alt
text instead. Here's simplified code:
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 ();
From what people are saying (such as here), it requires an AlternativeView
, which becomes MultipartAlternative
in MailKit
(sample here). But then how do you do the LinkedResources
, which is only supported on the BodyBuilder
object?
Thanks.