Solved

CSS Styling Outlook VBA HTML Email

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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Use these top 10 tips to master the art of email signature design. Create an email signature design that will easily wow recipients, promote your brand and highlight your professionalism.
Following basic email etiquette rules will help you write a professional email and achieve a good, lasting impression with your contacts.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

757 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

21 Experts available now in Live!

Get 1:1 Help Now