Search code examples
htmlvbaoutlookms-office

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

  • 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?