On 11 mei, 10:58, "Michael Bauer [MVP - Outlook]" <m...@mvps.org>
wrote:
> Not sure if it retains all the formattings, but in principle just loop
> through the Items collection and set each item's BodyFormat=2, then call
> Save.
Michael,
This is my code, still needs some cleanup:
Sub RTF2HTML()
On Error Resume Next
Dim ns As NameSpace
Dim Inbox As MAPIFolder
Dim Item As Object
Dim oldSize As Integer
Dim newSize As Integer
Set ns = GetNamespace("MAPI")
Set Inbox = ns.GetDefaultFolder(olFolderInbox)
If Inbox.Items.Count = 0 Then
MsgBox "There are no messages in the Inbox.", vbInformation, _
"Nothing Found"
Exit Sub
End If
For Each Item In Inbox.Items
If Item.BodyFormat = olFormatRichText Then
oldSize = Item.Size
Item.BodyFormat = olFormatHTML
Item.Save
newSize = Item.Size
Debug.Print oldSize & vbTab & newSize
End If
Next Item
End Sub
Some observations:
+ mails get converted from RTF to HTML
+ attachments move from inline to header
- size increases with the length of the HTMLBody. So the RTFBody
probably isn't removed from the mail.
- inline images are lost
Perhaps this is not the right way to go.
My goals are:
* Mail size should decrease, or increase only marginally
* Inline images should be preserved inline
* Inline images in RTF are uncompressed bitmaps, they should become
compressed images (PNG or whatever Outlook uses internally for
compressing embedded images in HTML mail). Quality loss is acceptable
to a certain degree, for example 85% JPEG compression would be fine.
FYI, this is the top of a converted email:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META NAME="Generator" CONTENT="MS Exchange Server version
6.5.7036.0">
<TITLE></TITLE>
</HEAD>
<BODY>
<!-- Converted from text/rtf format -->
After that the actual mail body starts.
Any ideas?
Kind regards,
Amedee Van Gasse