Archived Forum Post

Index of archived forum posts


Problems with parsing email headers

Jan 02 '17 at 12:49

I'm in the process of replacing my home-grown header parser with the Chilkat plugin and got some issues from my collected cabinet of email horrors:

  1. The following subject most likely isn't legal.

    Subject: Nie mehr kalte Füße -

Beheizte Hausschuhe jetzt 60

% reduziert - Restposten -

    "Nur noch 4,95 Euro - Solange "

der Vorrat reicht

Oddly the result is "Nie mehr kalte F" and the rest is missing.

  1. I've got a mail where the mail body is in content-disposition:

    Return-path: <> Envelope-to: Delivery-date: Fri, 03 Jun 2005 10:02:31 +0100 Received: from ([]) by with esmtp (Exim 4.34) id 1De84V-0006Bv-Nf for; Fri, 03 Jun 2005 10:02:31 +0100 Message-Id: <3bsvom$> Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="iso-8859-1" MIME-Version: 1.0 X-Mailer: MIME::Lite 2.117 (F2.72; T1.13; A1.55; B3.01; Q3.01) X-Mailer: Postman Email Date: Wed, 25 May 2005 17:16:50 UT Subject: CEWSS & My Canon To: Lines: 42

    Dear Customer,


    Your Canon Team X-SA-Exim-Connect-IP:

I could parse this myself but the value of the header doesn't have the returns anymore. Which is quite correct except for this lovely mail here.

The code is quite simple:

    Dim email As New Chilkat.Email
    email.PreferredCharset = "iso-8859-1"
    If not email.SetFromMimeText(OriginalHeader) Then
            Globals.theErrorLog.DialogErrorProceed(kErrorParse + email.LastErrorText)
            Globals.stopArchiving = True
    end If

    'loop through the header fields
    For currentHeader as Integer = 0 To email.NumHeaderFields - 1
            doTheParsing(email.GetHeaderFieldName(currentHeader), email.GetHeaderFieldValue(currentHeader))

In doTheParsing I fish out the individual header values.

As usual: Xojo 2016r4, Chilkat from July 2016, Mac OS 10.11.

Mit freundlichen Grüßen/Regards

Beatrix Willius Mail Archiver X: The email archiving solution for professionals


For the first problem (where the Subject begins with "Nie mehr kalte Füße") I'd need to have the .eml so I could reproduce the problem by loading it via LoadEml.

For the 2nd problem, I'm not sure there's anything that can be done. MIME headers lines must be terminated by CRLF line endings. (Chilkat can deal with CR-only or LF-only line endings, but there must be some line ending to mark the end of one header and the start of another..)



Thanks for sending the MIME to me..

I found the problem -- the line endings for the mime.txt were bare CR's. The line endings for headers in any MIME file, regardless of operating system, should be CRLF.

Chilkat handles LF-only line endings, and also auto-corrects as much "garbage" as possible. I made changes to auto-correct this case also, but I can't immediately get a new build out to you because of the time required to produce Xojo builds.

(I'm working on internal systems to better be able to quickly get new builds out. It's easy to produce new builds for .NET, ActiveX, C++, etc. because and individual build involves only a single operating system. Producing a new build (i.e. download) for Xojo involves building and gathering the DLLs/.so's for several operating systms, and that's why it's more time-consuming..)