Solved

CSS Styling Outlook VBA HTML Email

Posted on 2007-04-06
4
3,385 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

Zoho SalesIQ

Hassle-free live chat software re-imagined for business growth. 2 users, always free.

Question has a verified solution.

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

Resolve DNS query failed errors for Exchange
Not sure what the best email signature size is? Are you worried about email signature image size? Follow this best practice guide.
This video teaches viewers about errors in exception handling.
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.

920 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now