问题
I've been looking at some html templates for Outlook and I've found stuff like Cerberus and Foundation for emails, but none of these tell me how to actually use them. Unless I'm totally blind.
I've tried the obvious steps. Attaching a file in a new message and selecting "attach as text". This adds the html is seems. But the responsive css doesn't seem to be working. I've also tried opening the html file in Word and just copying the whole thing in a new message. Which seems to give the same result.
What am I doing wrong? And why isn't it obvious to me how to actually use these templates?
回答1:
We went through a similar challenge last year. We are a Mac shop, but I have built sizeable VB addins and feel confident in saying that VBA for Outlook is rubbish.
We have a customer that uses exchange server. We have to send emails on their behalf and we do all of this automatically using a python library called exchangelib. It allows you to define a nice html template, populate it with your variables, and then send things off. It also forms the basis for all of our email parsing activities...although not in scope for this question. I'm happy to share code if the Python option is of interest.
If you aren't into Python, you might consider something like MailChimp or any of those other marketing email providers. We also use them and it's quite easy to get through.
I hope this helps in any form.
回答2:
Edit again = I was able to successfully import an html file into the body of the outlook email and send it using a macro. The only issue on desktop was with skewed images and that can be fixed with hard-coding your width and height. I am not able to make it responsive and I don't think it's possible to do so sending from outlook.
Sub MakeHTMLMsg()
Set objMsg = Application.CreateItem(olMailItem)
Set fso = CreateObject("Scripting.FileSystemObject")
Set ts = fso.OpenTextFile("C:\filepath\template.html", 1)
strText = ts.ReadAll
objMsg.HTMLBody = strText
objMsg.Display
Set fso = Nothing
Set ts = Nothing
Set objMsg = Nothing
End Sub
My original answer below applies if you're sending to outlook, not from it.
How are you coding your email? Best practices for email HTML is to code it like it's 1999 and outlook is quite the outlier when it comes to using responsive CSS, unless you're using the mac version. Try also putting all your styles inline first or including your source code for us to see. I'm an email dev and marketer by trade.
Here are some links to get you started but we can't help you without seeing the template first: https://www.emailonacid.com/blog/article/email-development/coding-for-outlook-2016 https://litmus.com/community/learning/24-how-to-code-a-responsive-email-from-scratch
来源:https://stackoverflow.com/questions/42076877/outlook-how-to-use-html-as-a-template-with-css