1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Greetings Guest!!

    In order to combat SPAM on the forums, all users are required to have a minimum of 2 posts before they can submit links in any post or thread.

    Dismiss Notice

OT: Mass editing (search/replace) Outlook MSG files?

Discussion in 'UO Resources' started by Wulf2k, Jul 13, 2010.

  1. Wulf2k

    Wulf2k Stratics Legend
    Stratics Veteran Stratics Legend Crusader of Chaos

    Joined:
    Feb 27, 2004
    Messages:
    7,565
    Likes Received:
    314
    At work we've got a document management system in place here. The specifics don't matter, but suffice it to say, some of the HTML Outlook messages were converted incorrectly when being imported into the system. It turned
    Code:
    <STYLE>@font-face {
        font-family: Tahoma;
    }
    @page Section1 {size: 612.0pt 792.0pt; margin: 72.0pt 90.0pt 72.0pt 90.0pt; }
    P.MsoNormal {
        FONT-SIZE: 12pt; MARGIN: 0cm 0cm 0pt; FONT-FAMILY: "Times New Roman"
    
    blah blah blah
    
    DIV.Section1 {
        page: Section1
    }
    </STYLE>
    </HEAD>
    <BODY lang=EN-CA vLink=purple link=blue>
    Into

    Code:
    <STYLE>@font-face &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; font-family: Tahoma;@page Section1 size: 612.0pt 792.0pt; margin: 72.0pt 90.0pt 72.0pt 90.0pt; P.MsoNormal &nbsp;&nbsp;&nbsp;&nbsp; FONT-SIZE: 12pt; MARGIN: 0cm 0cm 0pt; FONT-FAMILY: "Times New Roman"LI.MsoNormal &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; FONT-SIZE: 12pt; MARGIN: 0cm 0cm 0pt; FONT-FAMILY: "Times New Roman"DIV.MsoNormal &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; FONT-SIZE: 12pt; MARGIN: 0cm 0cm 0pt; FONT-FAMILY: "Times New Roman"A:link &nbsp;&nbsp;&nbsp;&nbsp; COLOR: blue; TEXT-DECORATION: underlineSPAN.MsoHyperlink &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; COLOR: blue; TEXT-DECORATION: underlineA:visited &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; COLOR: purple; TEXT-DECORATION: underlineSPAN.MsoHyperlinkFollowed &nbsp;&nbsp;&nbsp;&nbsp; COLOR: purple; TEXT-DECORATION: underlineP.MsoAutoSig &nbsp; FONT-SIZE: 12pt; MARGIN: 0cm 0cm 0pt; FONT-FAMILY: "Times New Roman"LI.MsoAutoSig &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; FONT-SIZE: 12pt; MARGIN: 0cm 0cm 0pt; FONT-FAMILY: "Times New Roman"DIV.MsoAutoSig &nbsp;&nbsp;&nbsp;&nbsp; FONT-SIZE: 12pt; MARGIN: 0cm 0cm 0pt; FONT-FAMILY: "Times New Roman"SPAN.EmailStyle17 &nbsp; COLOR: windowtext; FONT-FAMILY: Arial; mso-style-type: personal-composeDIV.Section1 &nbsp;&nbsp;&nbsp; page: Section1</STYLE></HEAD><BODY lang=EN-CA vLink=purple link=blue>
    For those too disinterested to check, it removed all {, }, and carriage returns.

    The resulting HTML showed up fine in Outlook XP/2003, but when viewed in Outlook 2007 all these messages are missing the first paragraph of the message. Adding a single carriage return before the <body> tag makes everything all pretty again.

    My question:
    Does anybody know of any way of doing a search/replace in MSG files to change
    </head><body>

    into
    </head>
    <body>
    ?

    I'd try write a little utility to do it myself, but Outlook doesn't store the HTML in plaintext. Except for when it does. Damn inconsistent file formats....

    We're talking about 1,000,000ish msg files to search through, though a smaller number of them will be HTML, and of those, not 100% are affected.
     
  2. Ya... I hate that when I am building web pages and spaces get turned into non-breaking spaces once it is rendered.

    I don't know anything about this utility, but there are several you can find on a Google search that claim to search and replace characters across multiple files. What a headache!

    http://www.funduc.com/search_replace.htm
     
  3. Harlequin

    Harlequin Babbling Loonie
    Stratics Veteran

    Joined:
    Jun 11, 2008
    Messages:
    2,716
    Likes Received:
    32
    If they come in multiple formats, you might want to consider dealing with them as if they are all binary files. For binary files, you can try using a hex editor. Esp if the header information are all at the same offset.

    I haven't tried this program before, but looks like it might make things easier for you:

    http://www.chmaas.handshake.de/delphi/freeware/xvi32/xvi32.htm



    Has sample scripts/commands to show you how to verify whether a specific string is at a specific address, and only replace it with something else if true.:

    http://www.chmaas.handshake.de/delphi/freeware/xvi32/xviscr.htm