【发布时间】:2015-01-13 02:48:30
【问题描述】:
提前致谢。 我一直在研究允许使用 VBA 将 html 代码或 .html 文件导入到 Outlook 2010 电子邮件中的各种方法,但令我沮丧的是,我注意到所有导入技术似乎都会导致 HEAD 中包含的所有样式元素被剥离。
例如,当使用具有相同 html CSS 代码的 Thunderbird 时,它可以完美地工作,并且在发送收件人时,尽管有客户端(gmail、yahoo 等),但似乎也能获得样式。 Thunderbird 通过一个简单的 HTML 输入就能完美地完成这项工作。那么,为什么我要尝试通过 Outlook 来实现这一目标呢?简单来说就是客户想用outlook 2010。
我很难相信没有一些漂亮的工作可以防止 Outlook 删除此内容,然后在发送电子邮件时保留 HEAD 内容,以便响应式样式正常工作。
这是我目前一直在使用的
VBA 参考
- Visual Basic 应用程序
- Microsoft Outlook 14.0 对象库
- Microsoft Office 14.0 对象库
- Microsoft Word 14.0 对象库
- OLE 自动化
被剥离的代码
<head>
<meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0;" />
<style type="text/css">
body{width:100%;margin:0px;padding:0px;background:#444444;text-align:center;}
html{width: 100%; }
img {border:0px;text-decoration:none;display:block; outline:none;}
a,a:hover{color:#ee7716;text-decoration:none;}.ReadMsgBody{width: 100%; background-color: #ffffff;}.ExternalClass{width: 100%; background-color: #ffffff;}
table {border-collapse:collapse; mso-table-lspace:0pt; mso-table-rspace:0pt; }
.padtop10 {padding-top:10px;}
.main-bg{ background:#444444;}
.pads {padding:0px 15px 0px 15px;}
.mobdes{font-size:10px;}
@media only screen and (max-width:640px)
{
body{width:auto!important;}
.padtop10 {padding-top:0px;}
.main{width:100% !important;margin:0px; padding:0px;}
.two-column{width:100% !important;margin:0px; padding:0px;}
.mobileCenter{width: 100% !important; text-align: center!important;}
.two-left{width: 100% !important; text-align: center!important;}
.date{font:Bold 14px Arial, Helvetica, sans-serif; color:#ee7716;}
.mobdes{font-size:8px !important;}
.customobpad{padding-top:30px !important;}
}
@media only screen and (max-width:479px)
{
body{width:auto!important;}
.padtop10 {padding-top:15px;}
.main{width:100% !important;margin:0px; padding:0px;}
.two-column{width:100% !important;margin:0px; padding:0px;}
.mobileCenter{width: 100% !important; text-align: center!important;}
.two-left{width: 100% !important; text-align: center!important;}
.date{font:Bold 12px Arial, Helvetica, sans-serif; color:#ee7716;}
.mobilogo {height:49px; width:190px !important; padding-left:15px !important; margin-left:-15px;}
.pads {padding:0px 18px 0px 28px;}
.mobdes{font-size:8px !important;}
.customobpad{padding-top:30px !important;}
}
@media only screen and (max-width:800px)
and (orientation : landscape) {
body{width:auto!important;}
.padtop10 {padding-top:5px;}
.main{width:100% !important;margin:0px; padding:0px;}
.two-column{width:100% !important;margin:0px; padding:0px;}
.mobileCenter{width: 100% !important; text-align: center!important;}
.two-left{width: 100% !important; text-align: center!important;}
.date{font:Bold 12px Arial, Helvetica, sans-serif; color:#ee7716;}
.mobilogo {height:39px; width:172px; padding-left:15px !important; margin-left:-15px;}
.pads {padding:0px 18px 0px 28px;}
.mobdes{font-size:8px !important;}
.customobpad{padding-top:30px !important;}
}
</style>
</head>
用于导入的 VBA 宏代码
Sub InsertHTMLClean2()
Dim insp As Inspector
Set insp = ActiveInspector
If insp.IsWordMail Then
Dim wordDoc As Word.Document
Set wordDoc = insp.WordEditor
Dim FileToOpen As String
FileToOpen = InputBox("filename?")
wordDoc.Application.Selection.InsertFile FileToOpen, , False, False, False
End If
End Sub
我很欣赏许多开发人员说 Outlook 2010 无法保留头部信息,但我想知道是否有人找到了可行的解决方案。我主要对保留 MEDIA QUERIES CSS 感兴趣,因为在当前状态下,移动样式正在破坏。没有关于如何在 Outlook html 电子邮件中重新训练媒体查询 CSS 样式的任何建议。
再次感谢。
【问题讨论】:
标签: css vba import outlook media-queries