Macro insert HTML text

H

Heather

Outlook 2002

I receive messages that are 'undeliverable'. I read the message and
before I re-send it, I would like to run a macro to insert text at the
beginning of the message.

This works perfectly for incoming Rich Text messages I cannot get it
to work for HTML messages.

Any help much appreciated.

My coding is:

Sub InsertSampleText()

'Inserts text into forwarded messages

Dim myolapp As Outlook.Application
Dim myItem As Object
Dim myItemEditor As Integer
Dim sHTML1 As String
Dim sHTML2 As String

On Error GoTo Abort

Set myolapp = CreateObject("Outlook.Application")
Set myItem = myolapp.ActiveInspector.CurrentItem

'Test message class - 46=Undeliverable

If myItem.Class = 46 Then

If myolapp.ActiveInspector.EditorType = olEditorHTML Then
sHTML1 = "<html><head></head><body>"
sHTML2 = "</body></html>"

myItem.HTMLBody = sHTML1 & "This message has been
quarantined or mis-addressed " & _
"and has been forwarded to you as the intended
recipient." _
& vbCrLf & vbCrLf & myItem.HTMLBody & sHTML2

Else
myItem.Body = "This message has been quarantined or
mis-addressed " & _
"and has been forwarded to you as the intended
recipient." _
& vbCrLf & vbCrLf & myItem.Body

End If
End If

Abort:

MsgBox "Error"

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top