'SaveAs html without creating the subfolders with .xml files

I am trying to SaveAs all incoming emails as .html files but it creates a subfolder with each email.

Here is my code:

Public Sub ShowMessage(Item As Outlook.MailItem)
Dim path As String
path = "C:\Users\me\Desktop\"
Item.SaveAs path & Item.SenderName & ".htm", olHTML
End Sub

It gives me something like: "joe.htm" and a folder call "joe_files" with "colorschememapping.xml" and "filelist.xml" as well as "themedata.thmx"

Is there a way to save as without these files?

In Word I solved the problem by saving as Filtered HTML but it does not seem to be possible with Outlook.

Here is my code in MSWord:

ActiveDocument.SaveAs FileName:=Path, FileFormat:=wdFormatFilteredHTML

Or could it be possible to use the MailItem.BodyFormat to edit the item's body and then save it as html? That way we won't have all the automatic encoding of Outlook when it saves as HTML. (https://msdn.microsoft.com/en-us/library/office/ff869979.aspx)



Solution 1:[1]

Never mind... I solved it. By re-reading my question I just realized that the answer was right there.

item.SaveAs path & Item.SenderName & ".htm", olTxt

Somehow the support page of Microsoft does not mention that Filtered HTML works on their code but it actually does.

https://msdn.microsoft.com/en-us/library/office/ff868727.aspx?

Solution 2:[2]

Try to use olMHTML (10) format instead.

You can also simply read the HTMLBody property and save it as file - the problem might be Unicode characters - HTMLBody property is UTF-16, and an HTML file has to be 8 byte, so you need to convert it appropriately based on the value of the PR_INTERNET_CPID (which might not necessarily match the code page in the HTML body).

If using Redemption is an option (I am its author), it supports the olHTMLEmbeddedImages format it creates an HTML file with the image data inside the <img> tags. Outlook (which uses Word to render HTML message) does not like that, but both IE and Firefox should be fine. It embeds both the images already attached to the message as well as referenced images (which are downloaded):

  set Session = CreateObject("Redemption.RDOSession")
  Session.MAPIOBJECT = Application.Session.MAPIOBJECT
  set Item = Session.GetMessageFromID(Application.ActiveExplorer.Selection(1).EntryID)
  Item.SaveAs "c:\temp\HTMLWithImages.html", 1033 ' olHTMLEmbeddedImages

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1
Solution 2