login about faq

I have an email message with a Multipart/mixed content type. The get_NumParts() method returns 1 but the getBodyDecoded() returns an empty string. Below is an example of the mail I am trying to parse.

content-Type: multipart/mixed; boundary="----msg_border_oyclZ0HtKZ"

This is a multi-part message in MIME format.

------msg_border_oyclZ0HtKZ
Date: Mon, 26 Aug 2013 12:46:24 -0700
Content-Type: multipart/alternative; boundary="----alt_border_Fu87pgEhas_1"

------alt_border_Fu87pgEhas_1
Content-Type: text/plain;
    charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

Having trouble viewing this message? Click here=2E=20

------alt_border_Fu87pgEhas_1
Content-Type: text/html;
    charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<=21doctype html>
<html xmlns=3D=22http://www=2Ew3=2Eorg/1999/xhtml=22>
<body>
<p>This is an html document</p>
</body>

</html>

------alt_border_Fu87pgEhas_1--

------msg_border_oyclZ0HtKZ--

asked Aug 26 '13 at 22:15

mlcarey1959's gravatar image

mlcarey1959
1112

edited Aug 26 '13 at 23:59


MIME messages (such as this) are hierarchical and have a tree structure (just like XML). Conceptually, a MIME node can have child nodes, but the child nodes themselves (and the content within the child nodes) are not considered the "content" (i.e. body) of the parent. Typically, a MIME part (i.e. node) that is multipart, meaning that it has child nodes, will have no "content". It only has child nodes. It is only the leaf nodes that have a body. (Chilkat's XML API follows this same idea.)

Therefore, you should navigate to the leaf node, such as the "text/plain" or the "text/html" to get either the plain-text body or the HTML body.

link

answered Aug 27 '13 at 11:27

chilkat's gravatar image

chilkat ♦♦
11.8k316358421

Is this possible using CkMime?

(Aug 27 '13 at 12:42) mlcarey1959

Yes. Call GetPart(n) to get the Nth immediate child of a mime object. For example:

CkMime *child = mime.GetPart(0);   // Pass 0 to get the 1st child, 1 to get the 2nd, etc.
Check to make sure child is non-null. Your app will have to delete any objects returned by a Chilkat method. After getting the child, check the ContentType, if it's multipart (has NumParts > 0) then get that object's sub-parts, etc., until you reach the part where the content-type is text/plain or whatever you want..

link

answered Aug 27 '13 at 15:18

chilkat's gravatar image

chilkat ♦♦
11.8k316358421

Okay! I understand now. Thanks.

(Aug 27 '13 at 16:48) mlcarey1959
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or __italic__
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×6

Asked: Aug 26 '13 at 22:15

Seen: 1,570 times

Last updated: Aug 27 '13 at 16:48

powered by OSQA