Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

CSS Styling Outlook VBA HTML Email

Posted on 2007-04-06
4
3,516 Views
Last Modified: 2008-02-01
I have been given the task of styling an HTML email generated by Office
Outlook 2003 VBA Language

Stylewise, I would like to get some perspective on what is possible or not
possible with this.


I have also heard that there are changings coming in Outlook 2007 which
will render HTML email using the MS Word engine, dropping the use of IE
for this purpose.

http://developers.slashdot.org/developers/07/01/13/1911226.shtml

http://msdn2.microsoft.com/en-us/library/aa338200.aspx#Word2007MailHTMLandCSS2_IntroductiontoHTMLandCSSCapabilitiesinOutlook



The examples about OutLook VBA on the Microsoft Web site are very simplistic
'Set the HTMLBody of the item.
    Item.HTMLBody = "<HTML><H2>My HTML page.</H2><BODY>My
body.</BODY></HTML>"
    'Item displays HTML message.
    Item.Display


So my question would be can you use use css formating?
If so where do you state it or import it?


Could the a Item.HTMLBody = be modified to include:

<head>
<title>Untitled Document</title>
<style type="text/css">
<!--
.style3 {font-size: 12px}
-->
</style>
</head>

Or is the formatting done in an older way whereby the font and background
colors are stuffed in side the table cells?
0
Comment
Question by:LT1415
  • 2
4 Comments
 
LVL 76

Assisted Solution

by:David Lee
David Lee earned 165 total points
ID: 18867904
Yes, you can use CSS formating.  The Style declarations go in the usual spot, in the HEAD portion of the HTML document.  The style declarations really need to be in the HTML document as opposed to usings linked CSS style sheets.  The reason for that is if a user happens to view the message when not connected to the internet, then a linked style sheet wouldn't work.  

I've found it to be much easier to create the HTML document in a web page editor, e.g. FrontPage or DreamWeaver, and read the entire page in rather than put all the HTML code in the script.
0
 
LVL 13

Accepted Solution

by:
Mark_FreeSoftware earned 85 total points
ID: 18869371

this is also an example how you can include css in your page:

<HTML><H2>My HTML page.</H2><BODY style="color:#FF0000; font-weight:bold;">My body.</BODY></HTML>
0
 

Author Comment

by:LT1415
ID: 18869791
Thanks. Can I amend my question to ask about how would one embed an image, like a logo?
If you are using VBA inside of an Access form I'm not clear how this is accomplished.
Where does the image reside?

Also in reading some posts on the internet it looks like Outlook 2007 is a nightmare for css users, so it's back to tables and font tags
http://joe.hardy.id.au/blog/2006/11/21/broken-html-rendering-in-outlook-2007/
0
 
LVL 76

Assisted Solution

by:David Lee
David Lee earned 165 total points
ID: 18873660
Adding an image to an HTML message is no different than adding an image to any HTML document.  Simply insert an IMG tag.  To embed the image instead of linking to it follow the steps outlined in this article: http://www.outlookcode.com/d/code/htmlimg.htm
0

Featured Post

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Many people use more than one email account and so it becomes difficult for them to manage them when they use separate accounts,  so, in this article, I have shared an easy way to add Other Mail Accounts in your Google Inbox. It helps to combine all…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
Many of my clients call in with monstrous Gmail overloading issues with Outlook. A quick tip is to turn off the All Mail and Important folders from synching. Here is a quick video I made to show you how to turn off these and other folders in Gmail s…

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question