更新时间:2022-05-03 07:05:38
您必须使用LinkedResource;看看这个
You have to use a LinkedResource; have a look at this
using (LinkedResource image = new LinkedResource(@"c:\assets\image.jpg", "image/jpeg") { ContentId = "myimage" })
using (MailMessage mail = new MailMessage())
using (SmtpClient smtpClient = new SmtpClient())
{
smtpClient.Host = "smtp.alfki.com";
String body = @"
<html>
<head></head>
<body>
<img src=""cid:myimage"" />
</body>
</html>
";
AlternateView view = AlternateView.CreateAlternateViewFromString(body, null, "text/html");
view.LinkedResources.Add(image);
mail.IsBodyHtml = true;
mail.AlternateViews.Add(view);
mail.From = new MailAddress("John.Doe@alfki.com");
mail.To.Add("Jane.Doe@alfki.com");
mail.Subject = "An email with an inline image";
smtpClient.Send(mail);
}
它在.NET Core/Standard中工作.
It works in .NET Core/Standard.
我不能代表FluentMail;也许你可以没有?
I can not speak for FluentMail; maybe you can do without?