【发布时间】:2016-01-13 16:29:16
【问题描述】:
我正在使用 StringBuilder 构建电子邮件正文。我需要在电子邮件末尾插入一张图片作为签名。
我的图像位于我的 MVC 解决方案中的一个文件夹。我可以浏览的图像的来源,并且有效。
如果我浏览到: http://localhost/Content/images/CustomerSatisfaction.jpg,我得到了返回的图片,刚刚获取这张图片作为邮件正文的一部分
string imgSrc = string.Format("@{0}{1}", HttpContext.Current.Request.Url.Authority,
"/Content/images/CustomerSatisfaction.jpg");
StringBuilder sb = new StringBuilder();
sb.AppendLine("<html>");
sb.AppendLine("<body>");
sb.AppendLine(string.Format("<img src='{0}' alt='xxx'>", imgSrc));
sb.AppendLine("</body>");
sb.AppendLine("</html>");
我还为我的图像源尝试了几个版本:
string imgSrc = "~/Content/images/CustomerSatisfaction.jpg";
【问题讨论】:
标签: image asp.net-mvc-4 c#-4.0 html-email