对于asp.net–HTML电子邮件中的嵌入图像无法在手机上显示感兴趣的读者,本文将提供您所需要的所有信息,我们将详细讲解邮件内嵌html,并且为您提供关于ASP.NETMVC:如何使用控制器发送HT
对于asp.net – HTML电子邮件中的嵌入图像无法在手机上显示感兴趣的读者,本文将提供您所需要的所有信息,我们将详细讲解邮件内嵌html,并且为您提供关于ASP.NET MVC:如何使用控制器发送HTML电子邮件?、asp.net-mvc – 从Asp.net MVC发送HTML电子邮件的最佳方式是什么?、c# – 如何显示嵌入图像的html电子邮件(cid)?、css – HTML电子邮件中的字体颜色 – Gmail的宝贵知识。
本文目录一览:- asp.net – HTML电子邮件中的嵌入图像无法在手机上显示(邮件内嵌html)
- ASP.NET MVC:如何使用控制器发送HTML电子邮件?
- asp.net-mvc – 从Asp.net MVC发送HTML电子邮件的最佳方式是什么?
- c# – 如何显示嵌入图像的html电子邮件(cid)?
- css – HTML电子邮件中的字体颜色 – Gmail
asp.net – HTML电子邮件中的嵌入图像无法在手机上显示(邮件内嵌html)
嵌入图像的代码工作得很好,我不相信它有任何问题,但我在下面包含了一些快速示例代码,以防万一:
MailMessage mail = new MailMessage(); mail.To.Add("123@myemail.com"); mail.From = new MailAddress("456@ myemail.com"); mail.Subject = "Image sample - fails in mobile clients"; string Body = "Sample email text<img src=\"cid:imageId\" />"; AlternateView htmlView = AlternateView.CreatealternateViewFromString(Body,null,"text/html"); LinkedResource lr = new LinkedResource("myImage.jpg"); lr.ContentId = "imageId"; htmlView.LinkedResources.Add(lr); mail.AlternateViews.Add(htmlView); SmtpClient smtpClient = new SmtpClient(); smtpClient.Send(mail);
有谁知道为什么嵌入式图像不会在移动客户端上显示?更好的是,我怎样才能正确显示图像?
编辑:如果Outlook 2007(及更高版本)发送带有图像的电子邮件,则图像将在移动客户端和桌面客户端中正确显示.如果HTML格式的电子邮件与嵌入的图像一起发送,则图像不会在移动客户端中正确显示,而是在桌面客户端中正确显示.
Outlook如何能够自信地显示带有图像的电子邮件,但如果通过Web应用程序(使用嵌入图像)发送,则移动客户端会阻止图像.两者有什么区别?
解决方法
从MSDN开始:
The information in the ContentType
class is used to describe the data
contained in an e-mail message in such
a way that software that displays
e-mail can present the content in an
appropriate manner. ContentType is
used with the Attachment class to
specify the type of content in the
attachment.
Outlook能够了解附加图像的显示方式,但移动客户端需要更多信息.
ASP.NET MVC:如何使用控制器发送HTML电子邮件?
我想理想情况下我想通过电子邮件发送html而不是像往常一样通过ActionResult将其返回到浏览器.通过这种方式,我可以将电子邮件构建为视图,通过模型为其提供数据,然后使用标准.NET电子邮件内容将其激活.
这可行/这样做的方法?
谢谢,
解决方法
/// Static Method to render string - put somewhere of your choosing public static string RenderPartialToString(string controlName,object viewData) { ViewDataDictionary vd = new ViewDataDictionary(viewData); ViewPage vp = new ViewPage { ViewData = vd }; Control control = vp.LoadControl(controlName); vp.Controls.Add(control); StringBuilder sb = new StringBuilder(); using (StringWriter sw = new StringWriter(sb)) { using (HtmlTextWriter tw = new HtmlTextWriter(sw)) { vp.RenderControl(tw); } } return sb.ToString(); }
asp.net-mvc – 从Asp.net MVC发送HTML电子邮件的最佳方式是什么?
编辑:到目前为止我的解决方案是使用模板引擎(NHaml,StringTemplate.net).它有效,但我不希望在我的网站上有第二个模板引擎.
解决方法
c# – 如何显示嵌入图像的html电子邮件(cid)?
你有什么想法吗?
解决方法
我用base64图像数据(RFC 2557)替换了所有图像的cid引用,如下所示:
<img src="data:image/png;base64,RAAAtuhhx4dbgYKAAA7...more data....." alt="test">
您可以使用以下代码生成base64字符串:
string base64Str = Convert.ToBase64String(File.ReadAllBytes(@"C:\Temp\test.png"));
备注:不适用于IE6
css – HTML电子邮件中的字体颜色 – Gmail
<tr>
但是当我在gmail中打开这个电子邮件时,字体家族和黑色被gmail风格所覆盖.我通过Firebug看到这个:
正在使用紫色,而不是我想要的黑色,而字体系列则默认为arial,sans-serif.有没有人知道一种方式来安全地覆盖gmail强迫我的样式?
UPDATE
我将颜色改为非黑色,即#212a2c,颜色正确变化,但是字体仍然停留在arial上.
解决方法
关于asp.net – HTML电子邮件中的嵌入图像无法在手机上显示和邮件内嵌html的介绍已经告一段落,感谢您的耐心阅读,如果想了解更多关于ASP.NET MVC:如何使用控制器发送HTML电子邮件?、asp.net-mvc – 从Asp.net MVC发送HTML电子邮件的最佳方式是什么?、c# – 如何显示嵌入图像的html电子邮件(cid)?、css – HTML电子邮件中的字体颜色 – Gmail的相关信息,请在本站寻找。
本文标签: