Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Convert from plaintext to HTML

Status
Not open for further replies.

emozley

Technical User
Jan 14, 2003
769
GB
I have found several tutorials on writing code to convert HTML emails to plain text but not the other way round.

So far I have (in ThisOutlookSession):

Dim WithEvents olkInboxItems As Outlook.Items

Private Sub Application_Quit()
Set olkInboxItems = Nothing
End Sub

Private Sub Application_Startup()
Set olkInboxItems = Session.GetDefaultFolder(olFolderInbox).Items
End Sub

Private Sub olkInboxItems_ItemAdd(ByVal Item As Object)
If Item.Class = olMail Then
If Item.BodyFormat = olFormatPlain Then
Item.BodyFormat = olFormatHTML
Item.Save
End If
End If
End Sub

I am using Outlook 2002 - any ideas much appreciated.

Thanks

Ed

 
Should work if you get the e-mail body into a string and then set the HTML body to that.
Code:
Private Sub olkInboxItems_ItemAdd(ByVal Item As Object)
    If Item.Class = olMail Then
        If Item.BodyFormat = olFormatPlain Then
            Item.BodyFormat = olFormatHTML
            Item.Save

           'Read current body and set HTML body to match
            StringName = Item.Body
            Item.HTMLBody = StringName
            Item.Save

        End If
    End If
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top