Subject: part of a mime msg

From: Omar Tawakol <[email-masked]>
Date: Thu, 05 Dec 1996 19:06:40 -0800

Hi,

I am trying to use the c-client to get only one mime part of a message.
The short version of my question is:
 
What do I pass into the char* section parameter of 
mail_fetch_text so that only the desired part is returned?

Here's the details...

When I send the following string directly to an IMAP server:

A004 FETCH 4 BODY[2.1]
It returns the body of part 2.1 in message 4.  The structure
of message 4 is as follows:

part	content-type
1 	TEXT/PLAIN;charset=us-ascii (7 lines)
2 	MESSAGE/RFC822 (328 lines)
2.1 	TEXT/PLAIN;charset=us-ascii (7 lines)
2.2 	TEXT/HTML;charset=us-ascii (62 lines)
2.3 	TEXT/HTML;charset=us-ascii;name=www.stanford.edu (224 lines)

The question is, how do I use the c-client imap4rev1 Beta to do
the same?  I tried using mail_fetch_text.  If I pass in
a NIL for the char* section parameter, the function correctly retrieves
the whole text of the message.  

Here's the prototype for mail_fetch_text:
char *mail_fetch_text (MAILSTREAM *stream,unsigned long msgno,
			char *section, unsigned long *len,long flags);

Given the example message above, what do I pass into the
section parameter so that the mail_fetch_text return value
is only the body of the part I wanted (in the example above part 2.1)?
Should I use another function instead of mail_fetch_text?

I appreciate any help anyone may have.

Regards,
Omar.

====================
Omar Tawakol
[email-masked]

---

From: Mark Crispin <[email-masked]>
Date: Thu, 5 Dec 1996 19:16:18 -0800 (PST)

In general, it is better to send questions on how to program c-client directly
to me, as suggested in the c-client README file, instead of to the c-client
list.  This particular question was about programming details for as-yet
undocumented aspects of the latest imap-4.1 toolkit.  It's unlikely that very
many people would know the answer (and certainly not without analyzing the
source).

It is also highly recommended that you read the supplied programming
documentation (imap-4.1/docs/Internal.DOC) thoroughly.  Even though the new
interfaces are not defined yet, the old imap-4 ones described in that document
still work by means of compatibility macros; in particular mail_fetchbody()
works to fetch an arbitrary body part.

As for the new functions, if you look at the compatibility macros in mail.h
you will find that mail_fetch_body() is the function that you want.

mail_fetch_text() fetches the text portion of an RFC-822 message without
regard to MIME.  If the section field is empty, this is the top-level message
text; otherwise, it is the body text of a MESSAGE/RFC822 body part.  In other
words, mail_fetch_text() will fetch BODY[TEXT] for a null section or
BODY[2.1.TEXT] for section 2.1.