Subject: [Imap-uw] How to convert message in char* to BODY*?

From: Brad Goldsmith <[email-masked]>
Date: Fri, 10 Mar 2006 12:34:38 +1100

Dear List,

Is there was way of taking a mail message, stored in a string or a file 
on disk, and preparing it so it can be used with functions for 
manipulating mime messages.

I assume that I would need to start with something like |*mail_newbody 
|and then work from there. I was wondering if anyone could point me in 
the right direction to the other functions that will be needed to 
correctly fill out a BODY structure from a message in a string, not from 
a mailbox.

It looks like  rfc822_parse_msg(ENVELOPE **en, BODY **bdy, char *s, 
unsigned long i, STRING *b, char *host, char *tmp) will fit the bill but 
I am unsure on how the headers and body strings need to be broken up.

If anyone could offer any advice I would be grateful.

Cheers,
Brad
_______________________________________________
Imap-uw mailing list
[email-masked]
https://mailman1.u.washington.edu/mailman/listinfo/imap-uw

---

From: Mark Crispin <[email-masked]>
Date: Thu, 9 Mar 2006 17:51:51 -0800 (Pacific Standard Time)

The simple answer is that you place the message into a mailbox (using 
mail_append()), do mail_open(), and then use the various mail_fetch*() 
functions.

The slightly more complex answer is that if you really want a string or a 
file that isn't a mailbox, you should write a simple driver that opens a 
single-message mailbox from a file or a string.

Direct calls to rfc822_parse_msg() are NOT advisable.  Not even drivers 
make direct calls to the parsing routines any more.  The mail_*() 
abstraction exists for a reason; they provide a safe and supported 
interface that won't change in the future in subtle ways that will break 
your application.

It is also FAR more simple to do as I suggest than to call the parsing 
routines directly.  If you're still determined, then look at how 
mail_fetch_structure() works in mail.c to learn the needed secrets.  And 
be aware that this may change in the future, and thus you'll have to re-do 
the exercise each time a new version of c-client comes out.

Good luck....

-- Mark --

http://staff.washington.edu/mrc
Science does not emerge from voting, party politics, or public debate.
Si vis pacem, para bellum.
_______________________________________________
Imap-uw mailing list
[email-masked]
https://mailman1.u.washington.edu/mailman/listinfo/imap-uw