Exchange 2003 - Disable Incoming HTML Emails
Is it possible to disable incoming emails that are HTML, or to convert them from HTML to Plain Text on arrival?
This is for Exchange 2003.
The majority of the client machines are on Outlook 2000 if that makes a difference.
Thanks in advance.
April 21st, 2009 3:28pm
Hi,So far as I know, there is no way to convert or reject inbound HTML emails. Could you let me know why you don't like HTML format?Thanks,Elvis
Free Windows Admin Tool Kit Click here and download it now
April 23rd, 2009 9:33am
Hello,You can disable the same by writing custom VBA Program. Here is the code and follow the instruction.One of the big security risks (if not the biggest) coming from Microsoft Outlook is HTML email: malicious scripts, hidden images and frames - just enough to track your email or even bring down your computer. Unfortunately, Microsoft doesn't provide an easy way to turn HTML email off. Fortunately, Outlook provides rich object model accessible through VBA.
Whenever new email arrives to Outlook Inbox Application_NewMail() event happens. At this point we can loop through all unread email messages and convert them from HTML to plain text.
In your Outlook menu bar click "Tools" and select "Macro", then "Visual Basic Editor". VBA editor will show up. Enter the following code:
Private Sub Application_NewMail()
On Error Resume Next
Set oFolder = GetNamespace("MAPI").GetDefaultFolder(olFolderInbox)
For Each oNewItem In oFolder.Items.Restrict("[Unread] = 0")
s = oNewItem.HTMLBody
If Trim(s) <> "" Then 'convert to plain text
s = oNewItem.Body & vbCrLf & "/*HTMLBody*/" & vbCrLf & _
oNewItem.HTMLBody & vbCrLf & "/*End HTMLBody*/"
oNewItem.HTMLBody = ""
oNewItem.Body = s
oNewItem.Subject = "(*) " & oNewItem.Subject 'mark email subject
oNewItem.Save
End If
Next
End Sub
Now, on new email arrival, HTML messages will be marked with "(*)" in subject line and converted to plain text
When closing Outlook don't forget to save changes you made. Also set macros security level to medium - you'll be prompted on each macro encountered by Outlook. When starting Outlook click on "Enable Macros" button. General suggestion - disable message preview in Inbox folder
What if there are HTML emails in folders other than Inbox? What if you want to see converted email in HTML format? Let's get complicated. Replace the code you entered in previous step with the following:
Public WithEvents oItem As MailItem
Public WithEvents oInspector As Inspector
Public WithEvents oInspectors As Inspectors
Public WithEvents oControl As CommandBarButton
'track Inspectors
'(Inspector is a child window, displaying an Outlook item: email, task, note, etc.)
Private Sub Application_Startup()
Set oInspectors = Application.Inspectors
End Sub
'handle new email here
Private Sub Application_NewMail()
On Error Resume Next
Set oFolder = GetNamespace("MAPI").GetDefaultFolder(olFolderInbox)
For Each oNewItem In oFolder.Items.Restrict("[Unread] = 0")
s = oNewItem.HTMLBody
If Trim(s) <> "" Then 'convert to plain text
s = oNewItem.Body & vbCrLf & "/*HTMLBody*/" & vbCrLf & _
oNewItem.HTMLBody & vbCrLf & "/*End HTMLBody*/"
oNewItem.HTMLBody = ""
oNewItem.Body = s
oNewItem.Subject = "(*) " & oNewItem.Subject 'mark email subject
oNewItem.Save
End If
Next
End Sub
'if Outlook item is opened get its Inspector
Private Sub oInspectors_NewInspector(ByVal Inspector As Inspector)
Set oInspector = Inspector
On Error Resume Next
Set oItem = oInspector.CurrentItem 'if Item is not email message - error happens
End Sub
'open Inspector window
Private Sub oInspector_Activate()
If oItem Is Nothing Then Exit Sub 'if Item is not email message - leave
s = oItem.HTMLBody
If Trim(s) <> "" Then 'convert to plain-text
s = oItem.Body & vbCrLf & "/*HTMLBody*/" & vbCrLf & _
oItem.HTMLBody & vbCrLf & "/*End HTMLBody*/"
oItem.HTMLBody = ""
oItem.Body = s
oItem.Save
End If
If InStr(oItem.Body, "/*HTMLBody*/" & vbCrLf) > 0 Then 'load ShoHTML button to menu bar
Set oControl = oInspector.CommandBars("Menu Bar").FindControl(, , "ShowHTML")
If oControl Is Nothing Then
Set oControl = oInspector.CommandBars("Menu Bar").Controls.Add
oControl.Tag = "ShowHTML"
oControl.Caption = "ShowHTML"
End If
oControl.Visible = True
End If
End Sub
'convert email message back to HTML format
Private Sub oControl_Click(ByVal Ctrl As Office.CommandBarButton, CancelDefault As Boolean)
Dim sBody As String
Dim sHTML As String
Dim nStart As Long
Dim nEnd As Long
Set oItem = oInspector.CurrentItem
sBody = oItem.Body
nStart = InStr(sBody, "/*HTMLBody*/" & vbCrLf)
If nStart > 0 Then
sHTML = Mid(sBody, nStart + 14)
nEnd = InStr(sHTML, vbCrLf & "/*End HTMLBody*/")
If nEnd > 1 Then
sHTML = Left(sHTML, nEnd - 1)
If nStart > 1 Then sBody = Left(sBody, nStart - 1) Else sBody = ""
oItem.Body = sBody
oItem.HTMLBody = sHTML
If Left(oItem.Subject, 4) = "(*) " Then oItem.Subject = Mid(oItem.Subject, 5)
oControl.Visible = False
End If
End If
End Sub
'close Inspector window
Private Sub oInspector_Deactivate()
On Error Resume Next
oControl.Delete
End Sub
Note: the code was tested in Microsoft Outlook 2000. With minor changes it should work in other versions, supporting macros and VBA.
Arun Kumar | MCSE - 2K3 + Messaging | ITIL-F V3
April 24th, 2009 12:46am