Archive

Posts Tagged ‘Outlook’

How to edit or view Outlook email HTML source

April 1st, 2012

You might not know but more often than not, the email you compose and send out is in HTML format.

However, the email client software rarely allow you to edit the HTML source directly.
One recent use-case I have:

I want to put a yahoo emoticon into a Gmail composed email, not by attaching the image file, but a direct HTML img tag which shows the online image.

Obviously Gmail does not support coding HTML email.
There are many ways to do this, you could also sign up for some bulk email services that you can edit the HTML template, but that’s another story for sending more than one email.

So one easy way is to use Microsoft Outlook, edit the source and forward it to Gmail.

One thing is missing in some older Outlook versions though.
You cannot edit HTML source in Outlook directly.

Found the solution here: Outlook 2007: Edit your Messages HTML Source

Steps
1) Create a VB module with the following code
Create a module from Tools menu > Macros > Visual Basic Editor

Sub EditHTML()
Dim mit As MailItem
Dim fname As String
Dim fcon As String
If Application.ActiveInspector.CurrentItem.Class <> olMail Then
MsgBox “The HTML Code cannot be edit for this item.” & vbCrLf & “Only Mail Items are supported.”, vbExclamation, “Edit HTML Error”
Exit Sub
End If
Set mit = Application.ActiveInspector.CurrentItem
fname = Environ$(“temp”) & “\temptxt.txt”
On Error Resume Next
Kill fname
Open fname For Binary As #1
Put #1, , mit.HTMLBody
Close #1
Shell “notepad.exe ” & fname, vbMaximizedFocus
MsgBox “Click OK when Done and the saved HTML will be inserted to your message”, vbOKOnly + vbInformation, “Edit HTML”
Open fname For Binary As #1
fcon = Space(LOF(1))
Get #1, , fcon
Close #1
mit.HTMLBody = fcon
End Sub

2) Add ‘Edit HTML’ function to New message menu
Open a new message,
Click The Ribbon Customization Button
Select the “More Commands” Menu
Instead of “Popular Commands” Select the “Macros”

Select the new macro created named “Project1.EditHTML”
Select the EditHTML Macro
Click The “Add” Button, Customize the new button

3) Do the HTML editing!

Notepad will pop with the HTML source of the message
Do your editing
Close when done or if no changes performed

Credits to Udi!

Cheatsheet, Good To Know, Internet , ,