【发布时间】:2016-08-18 10:30:06
【问题描述】:
我正在使用 .cs 文件中的 html 代码来设计用于发送电子邮件的模板。我在<a href>标签中添加了style标签,但是在邮件实际发送时并没有生效。
代码如下:
public static void Email()
{
StringBuilder sb= new StringBuilder();
sb.Append("<a href='#' style='font-family:'Helvetica Neue',Helvetica,Arial,sans-serif;font-size:14px;color:#fff;text-decoration:none;line-height:2em;font-weight:bold;text-align:center;display:inline-block;border-radius:5px;text-transform:capitalize;background-color:#208ed5;margin:0;border-color:#208ed5;border-style:solid;border-width:10px 20px' target='_blank'>");
sb.Append("link</a>");
}
【问题讨论】:
-
我认为您应该在样式属性后使用双引号,例如
style = "font-family:'Helvetica Neue'; color: green; width: 100px;". -
字符串格式化问题
-
@Reddy 是的字符串格式问题,感谢您指出。我删除了
Helvetica Neue周围的单引号,现在它可以正常工作了。谢谢 -
@sumedha 从
Helvetica Neue中删除引号将不会采用此字体。 -
@sumedha 如果我的回答解决了您的问题,请将其标记为答案。