发送电子邮件与嵌入式图像,图像不显示在Gmail中
问题描述:
大家好我在学习学习编程的中间只是为了通知你,我不想提前学习所以这里是我的问题是当发送电子邮件使用流畅的电子邮件,Gmail不会显示我的嵌入式图像,当我检查元素时,它只显示空的img标签,但我可以附加图像,但不幸的是我不能在电子邮件内嵌入图像我到目前为止做了一些研究这是结果。发送电子邮件与嵌入式图像,图像不显示在Gmail中
我在这里使用的模板和我发送的图像是90 x 90并有JPG扩展名。
string authorImage = HttpContext.Current.Server.MapPath(@"~/img/author.jpg");
Attachment authorImageAtt = new Attachment(authorImage);
authorImageAtt.ContentDisposition.Inline = true;
authorImageAtt.ContentDisposition.DispositionType = DispositionTypeNames.Inline;
string authorImageId = "author";
authorImageAtt.ContentId = authorImageId;
model.ImgSrc = authorImageId;
var template =
System.IO.File.ReadAllText(HttpContext.Current.Server.MapPath(string.Format("~/Templates/{0}.cshtml", emailTemplate)));
var body = Razor.Parse(template, model);
var email = Email
.From("[email protected]")
.To(model.EmailTo)
.Subject(subject)
.Attach(authorImageAtt)
.Body(body).BodyAsHtml();
email.Send();
该视图。
@model MYAPP.Site.Models.Author
<h2>Image Below</h2>
<img src="cid:@Model.ImgSrc" />
我是怎么错过了,我会很感激任何人都可以点我在正确的道路 也是我在当地的发展。
答
正如@Etienne(计算器后)写在评论
mail.IsBodyHtml = true;
应该足够了这里。
请添加代码到问题的代码,而不是作为一个图像 – ASpirin
请添加代码 –
https://*.com/questions/18358534/send-inline-image-in-email – Etienne