Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

HTML Format in Outlook

Status
Not open for further replies.

AllanB1

Programmer
Dec 30, 2002
201
US
Is there a way to paste a block of HTML code/tags into an Outlook message and have the output appear with the desired formats?

If so, how?

Thank you.
 
Jock, tried your suggestion, which obviously worked for others.

When I "Insert As Text", the HTML code into a new HTML-formatted email, it appears as code and not as a final output should look.

Yet my signature block that is automatically-generated, has HTML code behind it when I view source.

After the code is inserted, should it immediately appear formatted, and not appear as the HTML code?

Any ideas?

Thanks.

 
Yes, it should appear immediately as html output, not code.

A few things to consider:

- The file you are inserting containing html code should be good code in the context of where you are insertin it in the overall html of the email. By that I mean you shouldn't be including <html>, </html>, <head>, </head>, <body> or </body> - they are already there. You can view source to see what has happened. Usually the html I insert is just a bare <table> </table> block. That is why I insert a pre-edited file containng the html rather than trying to paste it in so I know what is in there.

- What is your email editor? If you are using Word as your editor it may be problematic because the html created by Word is bizarre.

- What version of Outlook? I must admit I have only done this sort of thing with 2002 & 2003, not with 2007.

Jock
 
Still can't get it to work. Inserting a simple text file containing this:
Code:
 <b> TESTING </b>
Produced this source (Outlook 2003):
Code:
 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<META content="MSHTML 6.00.2900.3492" name=GENERATOR></HEAD>
<BODY>
<DIV><FONT face=Verdana size=2>&lt;b&gt; TESTING 
&lt;/b&gt;<BR></FONT></DIV></BODY></HTML>
And resuled in this output:
Code:
 <b> TESTING </b>
Appreciate further ideas. Thanks.
 
But works fine in 2002.

I was certain I did it the same way under 2003; possibly that changed with a service pack, or I just mis-remembered (wouldn't be the first time).

My only system with 2003 went away with the installation of Ubuntu, so can't verify it locally.

Obviously some difference between 2002 & (current version) of 2003.

Looking at your html output it is clear the greater thans & less thans are being escape coded on insert, which was not previously the case. Consequently html tags are not recognized as such.

So, it looks like this method won't work for you.

The only other way I have done this involved writing a macro to create an html email. I will post the essential bit of code here, even though forum admins don't like to see vbscript here (I guess they've never looked at the FAQ's). This snippet creates an HTML email by reading the html body, subject and to address from disk files:

Code:
        Rem --- Read HTML text, then delete file
        ForReading = 1
        Set ts = fso.OpenTextFile("C:\temp\Email.htm", ForReading)
        strText = ts.ReadAll
        ts.Close
        fso.DeleteFile ("C:\temp\Email.htm")
        
        Rem --- Read subject
        Set ts = fso.OpenTextFile("C:\te,[\Email.sub", ForReading)
        strSubj = ts.ReadAll
        ts.Close
        
        Rem --- Read to:
        Set ts = fso.OpenTextFile("C:\temp\Email.to", ForReading)
        strTo = ts.ReadAll
        ts.Close
        
        Rem --- Create HTML message
        Set NewMail = ThisOutlookSession.CreateItem(olMailItem)
        With NewMail
            .BodyFormat = olFormatHTML
            .Subject = strSubj
            .HTMLBody = strText
            .To = strTo
            .Display
        End With

It's the only way I can think of - and of course not tested in Outlook 2k3

Jock

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top