* Netmime: parsing a nested multipart message
@ 2005-06-14 13:55 Johann Spies
2005-06-15 6:11 ` [Caml-list] " Johann Spies
0 siblings, 1 reply; 2+ messages in thread
From: Johann Spies @ 2005-06-14 13:55 UTC (permalink / raw)
To: caml-list
I have to add a disclaimer on server level to emails.
In order to do that I want to add the disclaimer to the first
"`Body <obj>" of a message. At the moment I have success with
messages with the following stuctures:
Netmime.complex_mime_message = (<obj>, `Body <obj>)
and
(<obj>, `Parts [(<obj>, `Body <obj>); (<obj>, `Body <obj>);...])
but I am struggling with the following one:
- : Netmime.complex_mime_message =
(<obj>,
`Parts
[(<obj>, `Parts [(<obj>, `Body <obj>); (<obj>, `Body <obj>)]);
(<obj>, `Body <obj>); (<obj>, `Body <obj>); (<obj>, `Body <obj>)])
I cannot predict how deep the nesting would be and so far was
unsuccessful in my effort to parse the tree recursively to get the
first `Body <obj>)
I would appreciate some help please.
Regards
Johann
--
Johann Spies Telefoon: 021-808 4036
Informasietegnologie, Universiteit van Stellenbosch
"I beseech you therefore, brethren, by the mercies of
God, that ye present your bodies a living sacrifice,
holy, acceptable unto God, which is your reasonable
service." Romans 12:1
VRYWARING: Hierdie vrywaring is bloot 'n toets...
DISCLAIMER: This disclaimer was just added as a test...
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [Caml-list] Netmime: parsing a nested multipart message
2005-06-14 13:55 Netmime: parsing a nested multipart message Johann Spies
@ 2005-06-15 6:11 ` Johann Spies
0 siblings, 0 replies; 2+ messages in thread
From: Johann Spies @ 2005-06-15 6:11 UTC (permalink / raw)
To: caml-list
On Tue, Jun 14, 2005 at 03:55:28PM +0200, Johann Spies wrote:
>
> - : Netmime.complex_mime_message =
> (<obj>,
> `Parts
> [(<obj>, `Parts [(<obj>, `Body <obj>); (<obj>, `Body <obj>)]);
> (<obj>, `Body <obj>); (<obj>, `Body <obj>); (<obj>, `Body <obj>)])
>
Thanks to Remi Vanicat who helped me. The following code seems to
work:
# let handle ( mesg : Netmime.complex_mime_message) = match mesg with
(header,`Body bb) -> handle_simple_message mesg
| (header, `Parts body) ->
let rec aux body =
match body with
[] -> ()
| (_ , `Body b)::_ ->
if not (List.mem("US-diclaimer", "added") header#fields)
then
begin
add_header header;
add_disclaimer b;
writemessage mesg;
end
| (_, `Parts l)::_ -> aux l
in
aux body;
writemessage mesg;;
val handle : Netmime.complex_mime_message -> unit = <fun>
Regards
Johann
--
Johann Spies Telefoon: 021-808 4036
Informasietegnologie, Universiteit van Stellenbosch
"Cease from anger, and forsake wrath; do not fret-
it leads only to evil." Psalms 37:8
VRYWARING: Hierdie vrywaring is bloot 'n toets...
DISCLAIMER: This disclaimer was just added as a test...
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2005-06-15 6:11 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-06-14 13:55 Netmime: parsing a nested multipart message Johann Spies
2005-06-15 6:11 ` [Caml-list] " Johann Spies
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox