Sunday, March 14, 2010

How to Edit HTML Source in Outlook 2003 Message on XP

Also posted here

www.programmer.bz/Articles/tabid/159/asp_net_sql/157/How-to-Edit-Outlook-2003-Email-Message-HTML-Source.aspx

There was a brilliant post with a macro to edit the html source in Outlook 2003 on Windows XP. I made the tiniest of changes. Would
like to create the original poster, but the item was posted annonymously. Here is my version, using my naming conventions, but I
have to admit the original poster's was more readable. His (or hers) instructions were simpler too. Darn, someone smarter than me.

Instructions

1. In Outlook, go to Tools, Marco, Visual Basic Editor.

2. In the Visual Basic Editor

2.A Create a new Module (not a Class module) like Edit_Html.

2.B Copy in the code below.

2.C In the Visual Basic Editor go to Tools, References. Add references to Microsoft Scripting Runtime and Windows Scripting Host
Object Model.

2.D. Save

3. In Outlook, while editing an html message, press Alt + F8, select the macro Edit_Html.

Here is the code. Nice and simple

'----------------------------------------------------
Public Sub Edit_Html()
Dim filename As String
Dim filesystem As New Scripting.FileSystemObject
Dim item As mailitem
Dim shell As New WshShell
Dim filestream As TextStream
'----------------------------------------------------
' Put html body in a file
'----------------------------------------------------
Set item = ActiveInspector.CurrentItem
filename = filesystem.GetSpecialFolder(TemporaryFolder) & "\" & filesystem.GetTempName
Set filestream = filesystem.CreateTextFile(filename, True, True)
filestream.Write filename & item.HTMLBody
filestream.Close
'----------------------------------------------------
' Read file into wordpad
'----------------------------------------------------
Set filestream = Nothing
shell.Run "wordpad.exe """ & filename & """", , True
'----------------------------------------------------
' After exiting wordpad, read file into htmlbody
'----------------------------------------------------
Set filestream = filesystem.OpenTextFile(filename, ForReading, False, TristateTrue)
item.HTMLBody = filestream.ReadAll
filestream.Close
Set filestream = Nothing
End Sub
'----------------------------------------------------

www.DomainNames.gs for domain names

No comments:

Post a Comment