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 but when I run
the code on HTML messages, the text is inserted but the original
message is converted to strange characters.
I have tried setting my default editor to HTML and Rich text but this
has no effect.
Is it possible to do this? At present I have to ignore records where
the EditorType is 2.
Any help much appreciated.
Sue Mosher [MVP] - 04 Sep 2003 17:13 GMT
A code snippet might be illustrative.
If you're working with an HTML-format message, you should be setting HTMLBody and using fully tagged HTML text.

Signature
Sue Mosher, Outlook MVP
Outlook and Exchange solutions at http://www.slipstick.com
Author of
Microsoft Outlook Programming: Jumpstart
for Administrators, Power Users, and Developers
http://www.outlookcode.com/jumpstart.aspx
> Outlook 2002
>
[quoted text clipped - 13 lines]
>
> Any help much appreciated.
Heather - 29 Sep 2003 17:54 GMT
> Outlook 2002
>
[quoted text clipped - 13 lines]
>
> Any help much appreciated.
Thanks for your help.
The code below works for rich text but not HTML messages.
Sub InsertSampleText()
'Inserts text into new or 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><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:
End Sub