Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

CSS Styling Outlook VBA HTML Email

Posted on 2007-04-06
4
Medium Priority
?
3,903 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
[X]
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
  • 2
4 Comments
 
LVL 76

Assisted Solution

by:David Lee
David Lee earned 660 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 340 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 660 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

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

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

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…
When you have clients or friends from around the world, it becomes a challenge to arrange a meeting or effectively manage your time. This is where Outlook's capability to show 2 time zones in one calendar comes in handy.
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.
CodeTwo Sync for iCloud (http://www.codetwo.com/sync-for-icloud?sts=6554) automatically synchronizes your Outlook 2016, 2013, 2010 or 2007 folders with iCloud folders available via iCloud Control Panel. This lets you automatically sync them with…

704 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