简体   繁体   中英

Displaying message body from MIME encoded email string

We're discontinuing use of our Lyris ListManager account, but we still have access to the data in our SQL database. Clients would still like access to the message archives, so we're trying to find a way to take the encoded email message strings in the database and display them in a readable format in the browser. An example of the string for a single message:

--_004_D72176A059CDE746962E56C32F641BE3016734DDEDKCOEX2VKCOAD_
Content-Type: multipart/alternative;
    boundary="_000_D72176A059CDE746962E56C32F641BE3016734DDEDKCOEX2VKCOAD_"

--_000_D72176A059CDE746962E56C32F641BE3016734DDEDKCOEX2VKCOAD_
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: quoted-printable

Testing.  Please reply back if successful.

Thank you


[cid:image001.jpg@01D36CBE.C035BE50]
Jane Doe | Web Content Manager
jdoe@email.com<mailto:jdoe@email.com>

--_000_D72176A059CDE746962E56C32F641BE3016734DDEDKCOEX2VKCOAD_
Content-Type: text/html; charset="us-ascii"
Content-Transfer-Encoding: quoted-printable

<html xmlns:v=3D"urn:schemas-microsoft-com:vml" xmlns:o=3D"urn:schemas-micr=
osoft-com:office:office" xmlns:w=3D"urn:schemas-microsoft-com:office:word" =
xmlns:m=3D"http://schemas.microsoft.com/office/2004/12/omml" xmlns=3D"http:=
//www.w3.org/TR/REC-html40">
<head>
<meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3Dus-ascii"=
>
<meta name=3D"Generator" content=3D"Microsoft Word 14 (filtered medium)">
<!--[if !mso]><style>v\:* {behavior:url(#default#VML);}
o\:* {behavior:url(#default#VML);}
w\:* {behavior:url(#default#VML);}
.shape {behavior:url(#default#VML);}
</style><![endif]--><style><!--
/* Font Definitions */
@font-face
    {font-family:Calibri;
    panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
    {font-family:Tahoma;
    panose-1:2 11 6 4 3 5 4 4 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
    {margin:0in;
    margin-bottom:.0001pt;
    font-size:11.0pt;
    font-family:"Calibri","sans-serif";}
a:link, span.MsoHyperlink
    {mso-style-priority:99;
    color:blue;
    text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
    {mso-style-priority:99;
    color:purple;
    text-decoration:underline;}
p.MsoAcetate, li.MsoAcetate, div.MsoAcetate
    {mso-style-priority:99;
    mso-style-link:"Balloon Text Char";
    margin:0in;
    margin-bottom:.0001pt;
    font-size:8.0pt;
    font-family:"Tahoma","sans-serif";}
span.EmailStyle17
    {mso-style-type:personal-compose;
    font-family:"Calibri","sans-serif";
    color:windowtext;}
span.BalloonTextChar
    {mso-style-name:"Balloon Text Char";
    mso-style-priority:99;
    mso-style-link:"Balloon Text";
    font-family:"Tahoma","sans-serif";}
.MsoChpDefault
    {mso-style-type:export-only;
    font-family:"Calibri","sans-serif";}
@page WordSection1
    {size:8.5in 11.0in;
    margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
    {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext=3D"edit" spidmax=3D"1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext=3D"edit">
<o:idmap v:ext=3D"edit" data=3D"1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang=3D"EN-US" link=3D"blue" vlink=3D"purple">
<div class=3D"WordSection1">
<p class=3D"MsoNormal">Testing.&nbsp; Please reply back if succ=
essful.<o:p></o:p></p>
<p class=3D"MsoNormal"><o:p>&nbsp;</o:p></p>
<p class=3D"MsoNormal">Thank you,<o:p></o:p></p>
<p class=3D"MsoNormal"><o:p>&nbsp;</o:p></p>
<p class=3D"MsoNormal">Jane<o:p></o:p></p>
<p class=3D"MsoNormal"><o:p>&nbsp;</o:p></p>
<p class=3D"MsoNormal"><o:p>&nbsp;</o:p></p>
<p class=3D"MsoNormal" style=3D"margin-bottom:12.0pt;line-height:12.05pt;te=
xt-autospace:none">
<b><span style=3D"font-size:10.0pt;font-family:&quot;Arial&quot;,&quot;sans=
-serif&quot;"><img width=3D"90" height=3D"36" id=3D"_x0000_i1025" src=3D"ci=
d:image001.jpg@01D36CBE.C035BE50"></span></b><b><span lang=3D"EN-AU" style=
=3D"font-size:10.0pt;font-family:&quot;Arial&quot;,&quot;sans-serif&quot;">=
<o:p></o:p></span></b></p>
<p class=3D"MsoNormal"><b><span lang=3D"EN-AU" style=3D"font-size:10.0pt;fo=
nt-family:&quot;Arial&quot;,&quot;sans-serif&quot;">Jane Doe
</span></b><span lang=3D"EN-AU" style=3D"font-size:10.0pt;font-family:&quot=
;Arial&quot;,&quot;sans-serif&quot;">|<b>
</b>Web Content Manager<br>
<a href=3D"mailto:jdoe@email.com">jdoe@email.com</a><=
/span><o:p></o:p></p>
</div>
</body>
</html>

--_000_D72176A059CDE746962E56C32F641BE3016734DDEDKCOEX2VKCOAD_--

--_004_D72176A059CDE746962E56C32F641BE3016734DDEDKCOEX2VKCOAD_
Content-Type: image/jpeg; name="image001.jpg"
Content-Description: image001.jpg
Content-Disposition: inline; filename="image001.jpg"; size=1735;
    creation-date="Mon, 04 Dec 2017 12:14:25 GMT";
    modification-date="Mon, 04 Dec 2017 12:14:25 GMT"
Content-ID: <image001.jpg@01D36CBE.C035BE50>
Content-Transfer-Encoding: base64

/9j/4AAQSkZJRgABAQEAeAB4AAD/2wBDAAoHBwkHBgoJCAkLCwoMDxkQDw4ODx4WFxIZJCAmJSMg
IyIoLTkwKCo2KyIjMkQyNjs9QEBAJjBGS0U+Sjk/QD3/2wBDAQsLCw8NDx0QEB09KSMpPT09PT09
PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT3/wAARCAAkAFoDASIA
AhEBAxEB/8QAHwAAAQUBAQEBAQEAAAAAAAAAAAECAwQFBgcICQoL/8QAtRAAAgEDAwIEAwUFBAQA
AAF9AQIDAAQRBRIhMUEGE1FhByJxFDKBkaEII0KxwRVS0fAkM2JyggkKFhcYGRolJicoKSo0NTY3
ODk6Q0RFRkdISUpTVFVWV1hZWmNkZWZnaGlqc3R1dnd4eXqDhIWGh4iJipKTlJWWl5iZmqK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1Pv6DvXor3lnpy2mhaCNlhFMnmy/xXL7hkk9x/npXWQeCoNP8ADqaRpdy1rExzcShAzznu
Sf8APHFUofh3HDPHINRc+W4bHlDnBz61lU5npE48Sq0vdprTqZIsLbVPjHrllexLNbzaYqujdx8n
6+9VrC+vPhZrS6XqjyT+G7pz9muSMmAnsf6j8R3Fdnb+Flt/G934j+1szXFuIPI2cLjbzuz/ALPp
Wlq+kWeu6ZNYahEJYJRgjuD2IPYj1rU7DzjxG2pXHxdsW0u5s45pLAGzlugXiIO7O3Hc81sajo3j
rUNOubS81PQDbTRskmYHHykc89vrTI/hWh0mOxuNZuJTavvsZ1jCS2p7gHPKng44wRxinS/D/W9U
jFprni67udP6PDFCIzIPRmz/AI0AZOk6RcaD8QfCWm3kqTTW2mzoXjztIzIRjPPQgVyCmf8A4R3S
PLeJIv7eny04zEr/ACbS49Ov617B/wAIfAnifStWguHjj061NrHbld25SCASxOeM1TsPh5YQ+Frv
Qr6Z7uC4uHuBJtCNGxxjb15GOtAEX2L4hf8AQU0H/vxJXEan4VutDh0Wz1Ke1uY73XVlC2+dgDAB
hz9OldYvgLxFFALGLxpdrYAbQvkjzAvpuzmrz/DqySw0W0s7uaGPS7sXWXG9pm6nJyMZ9qAOk1dQ
2i3ysAQbeQEH/dNfLkZPlryegr6puoPtVpNBu2+bGybsZxkYrzBfgdCqgf27LwMf8ew/+KoA9Voo
ooAKKKKACiiigAooooAKKKKACiiigD//2Q==

--_004_D72176A059CDE746962E56C32F641BE3016734DDEDKCOEX2VKCOAD_--

Per some recommendations I've seen online, I'm trying to use MimeKit to do the parsing, but I'm not sure how to use it correctly. Ideally, we'd like to be able to grab just the message body. I've tried the following:

byte[] byteArray = Encoding.UTF8.GetBytes(row["body_"].ToString());
MemoryStream stream = new MemoryStream(byteArray);
var thisMssg = MimeMessage.Load(stream);
mssg.Text = thisMssg.TextBody;

But that results in "Failed to parse message headers."

I've also tried using the QuotedPrintableDecoder:

var decoder = new QuotedPrintableDecoder();
var buffer = Encoding.ASCII.GetBytes(row["body_"].ToString());
var output = new byte[decoder.EstimateOutputLength(buffer.Length)];
int used = decoder.Decode(buffer, 0, buffer.Length, output);
mssg.Text = System.Text.Encoding.ASCII.GetString(output, 0, used));

That at least outputs something semi-readable to the browser, but there are still headers and encoded text above and below the message.

Any help is appreciated. Most examples I've seen online deal with decoding an email file; I may be doing something wrong in trying to convert the string to bytes, or I could be totally off base about the whole thing.


UPDATE: this is working perfectly for some messages, but for others both the HtmlBody and TextBody are blank. I suspect I'm using the wrong encoding or something similar. Here's an example of the headers + body for one of the messages that's not returning anything:

Return-Path: <jane.doe@email.com>
Received: from z221.zixworks.com ([199.30.235.221]) by lyris.aosw.org with SMTP (Lyris ListManager WIN32 version 12.1.22); Mon, 17 Jun 2019 13:15:10 -0500
Received: from 127.0.0.1 (ZixVPM [127.0.0.1]) by Outbound.z221.zixworks.com (Proprietary) with SMTP id 66B33E18A0 for <groups@groups.org>; Mon, 17 Jun 2019 13:15:11 -0500 (CDT)
Received: from NAM02-SN1-obe.outbound.protection.outlook.com (mail-sn1nam02lp2056.outbound.protection.outlook.com [104.47.36.56]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by z221.zixworks.com (Proprietary) with ESMTPS id 77467E3E1C for <groups@groups.org>; Mon, 17 Jun 2019 13:15:07 -0500 (CDT)
Received: from BN8PR08MB5748.namprd08.prod.outlook.com (20.179.78.79) by BN8PR08MB6161.namprd08.prod.outlook.com (20.179.77.220) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1987.10; Mon, 17 Jun 2019 18:15:03 +0000
Received: from BN8PR08MB5748.namprd08.prod.outlook.com ([fe80::bdd9:7aa6:33e8:8c7f]) by BN8PR08MB5748.namprd08.prod.outlook.com ([fe80::bdd9:7aa6:33e8:8c7f%3]) with mapi id 15.20.1987.014; Mon, 17 Jun 2019 18:15:03 +0000
From: Jennifer Blosser <jane.doe@email.com>
To: test  List <groups@groups.org>
Subject: test subject
Thread-Topic: test subject
Thread-Index: AdUlODR9gfN51vIpRPKLoCMeLjIytQ==
Date: Mon, 17 Jun 2019 18:15:03 +0000
Message-ID:  <BN8PR08MB5748C0A8D6881BF572B3B3FE9DEB0@BN8PR08MB5748.namprd08.prod.outlook.com>
Accept-Language: en-US
Content-Language: en-US
X-MS-Has-Attach: yes
X-MS-TNEF-Correlator: 
authentication-results: spf=none (sender IP is ) smtp.mailfrom=jane.doe@email.com;
x-originating-ip: [199.87.130.130]
x-ms-publictraffictype: Email
x-ms-office365-filtering-correlation-id: 097c72d7-a379-49ac-dce6-08d6f34fb836
x-microsoft-antispam:  BCL:0;PCL:0;RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600148)(711020)(4605104)(1401327)(2017052603328)(49563074)(7193020);SRVR:BN8PR08MB6161;
x-ms-traffictypediagnostic: BN8PR08MB6161:
x-ms-exchange-purlcount: 4
x-microsoft-antispam-prvs:  <BN8PR08MB6161B55A933D7DEFA32FE4D69DEB0@BN8PR08MB6161.namprd08.prod.outlook.com>
x-ms-oob-tlc-oobclassifiers: OLM:10000;
x-forefront-prvs: 0071BFA85B
x-forefront-antispam-report:  SFV:NSPM;SFS:(10019020)(39860400002)(376002)(136003)(366004)(346002)(396003)(199004)(189003)(74316002)(7736002)(102836004)(99286004)(81166006)(66946007)(73956011)(81156014)(7696005)(2906002)(316002)(786003)(861006)(6506007)(66556008)(66476007)(66616009)(68736007)(26005)(8936002)(476003)(8676002)(76116006)(186003)(6916009)(99936001)(6306002)(55016002)(54896002)(6436002)(44832011)(478600001)(86362001)(64756008)(53936002)(5660300002)(733005)(54556002)(606006)(66446008)(33656002)(6116002)(256004)(25786009)(3846002)(790700001)(14454004)(66066001)(52536014)(71200400001)(71190400001)(486006)(9686003)(236005);DIR:OUT;SFP:1102;SCL:1;SRVR:BN8PR08MB6161;H:BN8PR08MB5748.namprd08.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;A:1;MX:1;
received-spf: None (protection.outlook.com: vcuhealth.org does not designate permitted sender hosts)
x-ms-exchange-senderadcheck: 1
x-microsoft-antispam-message-info:  pg6USXqqMlMkBtJyhBsn236QA/k0rF3vQc1WC61WuHvtUFLFrPjeTUEQMYlbPZTU5UJKiehb0WLAKiT4R98gsNeqkREMejsaHxqIgNKTAyZbJ57JaHQmWu1rb9LY+gl+AhP+UXX2BM1WKGNxpc2ySYqeERX52xy/6cYrGPYPNoVvDryIGYBJslLwbyBh25k011jjA18szgKSKIhRu3QnN91aBu/7cTlDVY+/+f00xDMb62g4HWOVHzadxvXbmKv2duvVA1hzI/WTCWkJsg6XLXIBJ/gzip8lNGobi+cJ6a8VqY98CHd7z3vh8PE+4GgJv9UOUgrvW/q9Z6/TU8pfVtSh+5np5hhBRmjX80ZOpVzrjPrXufIe1uJ0hD1cIA4Jx4YcJOqQKsP5OQLAsBRj06/+VAKeswwGNbh2judAif0=
Content-Type: multipart/related; boundary="_004_BN8PR08MB5748C0A8D6881BF572B3B3FE9DEB0BN8PR08MB5748namp_"; type="multipart/alternative"
MIME-Version: 1.0
X-OriginatorOrg: vcuhealth.org
X-MS-Exchange-CrossTenant-Network-Message-Id: 097c72d7-a379-49ac-dce6-08d6f34fb836
X-MS-Exchange-CrossTenant-originalarrivaltime: 17 Jun 2019 18:15:03.6434 (UTC)
X-MS-Exchange-CrossTenant-fromentityheader: Hosted
X-MS-Exchange-CrossTenant-id: d21f3866-8fc6-4527-8622-cefa47fe9632
X-MS-Exchange-CrossTenant-mailboxtype: HOSTED
X-MS-Exchange-CrossTenant-userprincipalname: jane.doe@email.com
X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN8PR08MB6161
X-VPM-MSG-ID: 77fdc5a9-05b8-4e6c-8d21-912176d50a8c
X-VPM-HOST: vmvpm01.z221.zixworks.com
X-VPM-GROUP-ID: 994c5cd5-4e57-4cea-8f46-45e001662312
X-VPM-ENC-REGIME: Plaintext
X-VPM-IS-HYBRID: 0

    --_004_BN8PR08MB5748C0A8D6881BF572B3B3FE9DEB0BN8PR08MB5748namp_
Content-Type: multipart/alternative;
    boundary="_000_BN8PR08MB5748C0A8D6881BF572B3B3FE9DEB0BN8PR08MB5748namp_"

--_000_BN8PR08MB5748C0A8D6881BF572B3B3FE9DEB0BN8PR08MB5748namp_
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: quoted-printable

SWON:  Please see information below about CEU offering from Be The Match in=
 July. Mercury SWON co-moderator:

Be sure to attend our upcoming webinar, Sickle Cell Disease: Exploring Trea=
tment Options and Psychosocial Care.<https://urldefense.proofpoint.com/v2/u=
rl?u=3Dhttps-3A__go.pardot.com_l_566592_2019-2D06-2D10_gmysfg-3Futm-5Fsourc=
e-3DListserv-5Fdet-26utm-5Fmedium-3Demail-26utm-5Fcampaign-3Dhp-5Fwebinar-5=
F3&d=3DDwMFAg&c=3DpOo6bKNCxsIK6eGC4MYY4A&r=3DM89Ut5RE0fhAI4OPWxaYquIrnvWNHf=
gw4xuTI66ezb0&m=3Dc_yC0-6_GJEEXNI3WxSORby7ZMI668MQiTaQiXl-lOs&s=3DRFAiVjmSs=
QOwCOOAFqGIdtAOvr2St6TOLjS19nfvU7M&e=3D>

message body here.


--_000_BN8PR08MB5748C0A8D6881BF572B3B3FE9DEB0BN8PR08MB5748namp_
Content-Type: text/html; charset="us-ascii"
Content-Transfer-Encoding: quoted-printable

<html xmlns:v=3D"urn:schemas-microsoft-com:vml" xmlns:o=3D"urn:schemas-micr=
osoft-com:office:office" xmlns:w=3D"urn:schemas-microsoft-com:office:word" =
xmlns:m=3D"http://schemas.microsoft.com/office/2004/12/omml" xmlns=3D"http:=
//www.w3.org/TR/REC-html40">
<head>
<meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3Dus-ascii"=
>
<meta name=3D"Generator" content=3D"Microsoft Word 15 (filtered medium)">
<!--[if !mso]><style>v\:* {behavior:url(#default#VML);}
o\:* {behavior:url(#default#VML);}
w\:* {behavior:url(#default#VML);}
.shape {behavior:url(#default#VML);}
</style><![endif]--><style><!--
/* Font Definitions */
@font-face
    {font-family:"Cambria Math";
    panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
    {font-family:Calibri;
    panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
    {margin:0in;
    margin-bottom:.0001pt;
    font-size:11.0pt;
    font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
    {mso-style-priority:99;
    color:#0563C1;
    text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
    {mso-style-priority:99;
    color:#954F72;
    text-decoration:underline;}
span.EmailStyle17
    {mso-style-type:personal-compose;
    font-family:"Calibri",sans-serif;
    color:windowtext;}
.MsoChpDefault
    {mso-style-type:export-only;
    font-family:"Calibri",sans-serif;}
@page WordSection1
    {size:8.5in 11.0in;
    margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
    {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext=3D"edit" spidmax=3D"1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext=3D"edit">
<o:idmap v:ext=3D"edit" data=3D"1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang=3D"EN-US" link=3D"#0563C1" vlink=3D"#954F72">
<div class=3D"WordSection1">
<p class=3D"MsoNormal"><o:p>&nbsp;</o:p></p>
<p class=3D"MsoNormal">message body here.</p>
<p class=3D"MsoNormal"><o:p>&nbsp;</o:p></p>
</td>
</tr>
</tbody>
</table>
<p class=3D"MsoNormal"><o:p>&nbsp;</o:p></p>
<p class=3D"MsoNormal"><o:p>&nbsp;</o:p></p>
<p class=3D"MsoNormal"><o:p>&nbsp;</o:p></p>
</div>
</body>
</html>

--_000_BN8PR08MB5748C0A8D6881BF572B3B3FE9DEB0BN8PR08MB5748namp_--

--_004_BN8PR08MB5748C0A8D6881BF572B3B3FE9DEB0BN8PR08MB5748namp_
Content-Type: image/jpeg; name="image001.jpg"
Content-Description: image001.jpg
Content-Disposition: inline; filename="image001.jpg"; size=3521;
    creation-date="Mon, 17 Jun 2019 18:15:03 GMT";
    modification-date="Mon, 17 Jun 2019 18:15:03 GMT"
Content-ID: <image001.jpg@01D52517.0DFABF70>
Content-Transfer-Encoding: base64

/9j/4AAQSkZJRgABAQEAYABgAAD/2wBDAAoHBwgHBgoICAgLCgoLDhgQDg0NDh0VFhEYIx8lJCIf
IiEmKzcvJik0KSEiMEExNDk7Pj4+JS5ESUM8SDc9Pjv/2wBDAQoLCw4NDhwQEBw7KCIoOzs7Ozs7
Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozv/wAARCABAAQQDASIA
AhEBAxEB/8QAHwAAAQUBAQEBAQEAAAAAAAAAAAECAwQFBgcICQoL/8QAtRAAAgEDAwIEAwUFBAQA
AAF9AQIDAAQRBRIhMUEGE1FhByJxFDKBkaEII0KxwRVS0fAkM2JyggkKFhcYGRolJicoKSo0NTY3
ODk6Q0RFRkdISUpTVFVWV1hZWmNkZWZnaGlqc3R1dnd4eXqDhIWGh4iJipKTlJWWl5iZmqKjpKWm
p6ipqrKztLW2t7i5usLDxMXGx8jJytLT1NXW19jZ2uHi4+Tl5ufo6erx8vP09fb3+Pn6/8QAHwEA
AwEBAQEBAQEBAQAAAAAAAAECAwQFBgcICQoL/8QAtREAAgECBAQDBAcFBAQAAQJ3AAECAxEEBSEx
BhJBUQdhcRMiMoEIFEKRobHBCSMzUvAVYnLRChYkNOEl8RcYGRomJygpKjU2Nzg5OkNERUZHSElK
U1RVVldYWVpjZGVmZ2hpanN0dXZ3eHl6goOEhYaHiImKkpOUlZaXmJmaoqOkpaanqKmqsrO0tba3
uLm6wsPExcbHyMnK0tPU1dbX2Nna4uPk5ebn6Onq8vP09fb3+Pn6/9oADAMBAAI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Lr
GnXerXVhYhpYLWIefLOmM714RRn35/Ct/FG0VXPLch0onManoN9biDUrbULy/urKQSRwylPnB4ZR
gDqM1o6zBNcx6eYYmbZfRSOO6qM5J+la20UbRRzy08g9mtbdTL1/Tp9Qso2tGVbq1mWeDd91mHY+
xBIqp/b2oNEYo/D96LvGNr7RED7vnp9K6DGaTApKWlmhyg27p2MG50+e68S6bcXFqkkMdrKsxwGR
XO3A5/Gn6rpi/a9KktLNAIrwPI0aAbV2tyfatvAFG0GnzvTyF7Na+f8AwBaKKKg2Pn9H2SI46qQR
n2Oa0V8QXw1gao8hllVnZEdiVTcCCB6dazKK+qlCMt0fGRnKOzNU6/cS3JnuYY7gyWwtp1cn98o6
EkHIPA5HpUkHia6hvZ7p4IZTK6OEbICMgwuMHOAOMdxWNRUewp9i/b1O5r23iS8tUkjRU8uaWSWV
MkB964IOOw7UxNeuU0k6WIofsxhMRBT5uW3bs9c57dKy6KfsafYPb1O5tr4qv1hEO2Ixgk7cHvH5
f8ufrWXY8X1qB085P/QhUFT2X/H/AGv/AF3T/wBCFHs4wi+VAqkptczPe6KKK+XPrwooooAKKKKA
EpcUUUAJS0UUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQB/9k=

--_004_BN8PR08MB5748C0A8D6881BF572B3B3FE9DEB0BN8PR08MB5748namp_--

Does the QuotedPrintableDecoder method need to come into play? I've reviewed http://www.mimekit.net/docs/html/Working-With-Messages.htm , but I'm hoping I don't have to manually traverse each part and there's still a way to grab just the message body.

The problem you're hitting with MimeKit giving you an error about failing to parse the headers is due to the fact that your string is missing the message headers.

What you're effectively doing is asking a MIME parser to parse a message starting half way into the message. You're giving it an impossible task.

You need to combine the original message headers with the above string to produce the original (complete) message source before you can parse it.

Either that or you have to fake the original message headers so that things parse correctly.

Presumably you have the original message headers somewhere in your database?

Does the QuotedPrintableDecoder method need to come into play? I've reviewed http://www.mimekit.net/docs/html/Working-With-Messages.htm , but I'm hoping I don't have to manually traverse each part and there's still a way to grab just the message body.

There's generally no need to use any of the low-level decoders (or encoders) yourself.

There are multiple ways to get the message body:

  1. Traversing the MIME tree manually (but in general I wouldn't recommend it), but to do this you really need to understand how MIME is structured and how common mail clients will structure their messages. It's not something I would generally recommend unless you are well-read on MIME. (Difficulty: Extreme)
  2. Using a MimeIterator . For the most part, I wouldn't bother with this approach unless you want to manually traverse the MIME tree structure without using any sort of recursion. Where this class really comes in handy is if you are implementing something more akin to an IMAP server. Again, you need to understand how MIME works to really make use of this. See the documentation for a simple example on how to use this. (Difficulty: Extreme)
  3. Using a MimeVisitor subclass to traverse the MIME tree structure. For a good example on how to do this, I would recommend taking a look at the HtmlPreviewVisitor class in the example in the documentation. This is probably the best way to do things if you want to "render" the message like a mail client might. (Difficulty: Moderate)
  4. If all you want is the quick & dirty way of getting a message body and you don't care about trying to render the message the same way Outlook or GMail do, then you can use the MimeMessage.TextBody and/or MimeMessage.HtmlBody properties. (Difficulty: Easy Mode)

If I were you, I'd probably choose between the TextBody / HtmlBody properties and using something similar to the HtmlPreviewVisitor class in the example docs. They will be the simplest way to accomplish what you want to do.

user3562286,

I'm basically trying to do the exact same thing you set out to do here, and wondered if you'd be willing to share any other tips you learned the hard way since you originally asked this question?

Basically, I have access to ListManager SQL db, and would like to export list message data from the "messages_" table and import it into our current MySQL db, so that I can then create some pages on a Joomla / PHP-based website that would deliver the list archives.

Did you end up using MimeKit? Did you use that to convert the data in the field "Body_"? Did you have to combine that with any of the Hdr fields?

Thanks for any help you can offer!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM