• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 419
  • Last Modified:

outlook 2007 rules to export mail as html


I would like to set a rule that message from a certain sender are automatically saved/exported as html in aan dir on my hard disk. How can I do this?

1 Solution
You can export mail to a public folder that exists in Outlook or on your server with a standard rule.
DennieAuthor Commented:
can you please write the steps. I can't find it
Open Outlook
Click on Tools
Rules and Alerts
New Rule
Move messages from someone to a folder

And you click next to select the criteria for the email messages you want to send to a folder, whether it's from a person, a group or with certain words in the subject line, etc.  But you need a public folder created where you want these to go.
Easily manage email signatures in Office 365

Managing email signatures in Office 365 can be a challenging task if you don't have the right tool. CodeTwo Email Signatures for Office 365 will help you implement a unified email signature look, no matter what email client is used by users. Test it for free!

DennieAuthor Commented:
Yes, but I want to export them to a directory outside outlook in HTML format... that doesn't seem possible with your steps
DennieAuthor Commented:
Just as the 'save as' button does when viewing an e-mail
I don't know of any way to make that happen unless the rules do that.  Sorry!
You cannot create a rule for something which is outside the outlook. Outlook rules only work within Outlook and they run only when outlook is open. What you are looking for is not possibe.
DennieAuthor Commented:
The rule isn't for something outside outlook!

I just want to simulate the save as button (which is available in outlook) I'm sure it's possible. Perhaps not as easy as just simply clicking the new rule button ;)
DennieAuthor Commented:
Perhaps a little custom script?
Hi again, yes I can help. You will need to create the rule for the sender then run the script below. You will need to modify the folders to suit. I use this to save as text files but have modified it here to save as html, I don't know if the outputted html will be to your liking, you will have to check all that. You may or may not wish to delete the original email, it should be fairly obvious how to turn this on or off.

Option Explicit
Sub Save_Email_as_html(mItem As Outlook.MailItem)
    Dim StrSubject      As String
    Dim StrName         As String
    Dim StrFile         As String
    Dim strFolderPath   As String
    Dim StrSaveFolder   As String
    Dim myOLApp         As Outlook.Application
    Dim FSO             As Object

    Set FSO = CreateObject("Scripting.FileSystemObject")
    Set myOLApp = Outlook.Application

    strFolderPath = "C:\Temp"
    If MsgBox("Email item " & """" & mItem & """" & vbCrLf & _
    "Will be output as html to: " & strFolderPath, vbQuestion + vbOKCancel) = vbCancel Then
    GoTo Exitsub:

    End If

        StrSaveFolder = "C:\Temp" & "\"

        If Not FSO.FolderExists(strFolderPath) Then
            FSO.CreateFolder (strFolderPath)
        End If
            StrSubject = mItem.Subject
            StrName = StripIllegalChar(StrSubject)
            StrFile = StrSaveFolder & StrName
            StrFile = StrFile & ".html"
            mItem.SaveAs StrFile, olHTML
            'Delete original email
End Sub
Private Function StripIllegalChar(StrInput)
    Dim RegX            As Object
    Set RegX = CreateObject("vbscript.regexp")
    RegX.Pattern = "[\" & Chr(34) & "\!\@\#\$\%\^\&\*\(\)\=\+\|\[\]\{\}\`\'\;\:\<\>\?\/\,]"
    RegX.IgnoreCase = True
    RegX.Global = True
    StripIllegalChar = RegX.Replace(StrInput, "")

    Set RegX = Nothing
End Function

Open in new window

DennieAuthor Commented:
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free tool for managing users' photos in Office 365

Easily upload multiple users’ photos to Office 365. Manage them with an intuitive GUI and use handy built-in cropping and resizing options. Link photos with users based on Azure AD attributes. Free tool!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now