E-mail formating. 
Author Message
 E-mail formating.


Quote:

>Hi ppl.

>Lets say I've an e-mail in this forma:

>From tst3 Tue May 18 16:54:29 1999
>Date: Tue, 18 May 1999 16:54:29 +0100 (BST)
>From: User of Tst <tst3>

>Content-Length: 6

>blah blahb alh
>blahblahblah blah blah blah
>blah blahb alh
>blahblahblah blah blah blah

><END>

>How can I extract from this file only the body of the message?

Just delete the stuff up through the first blank line.

something like:

awk 'NR>1 && /^$/{cnt++} cnt!=0 {print}' email_file > body_file

the NR>1 is there in case there were a blank first line.  It shouldn't
be necessary.  This should be sufficient:

awk '/^$/{cnt++} cnt!=0 {print}' email_file > body_file

Chuck Demas
Needham, Mass.

--
  Eat Healthy    |   _ _   | Nothing would be done at all,

  Die Anyway     |    v    | That no one could find fault with it.



Sat, 03 Nov 2001 03:00:00 GMT  
 E-mail formating.
If you are not insist on awk use sed:

  ... | sed -e '1,/^$/d' | ...

This deletes everything from the first line until the first empty
line inclusive.

Andreas

--
Andreas Sons             | E-Mail : sons [at] hanse.de
Hamburg-Altona           | WWW    : http://www.signal.hanse.de
Germany                  | Handle : AS6076-RIPE



Sat, 03 Nov 2001 03:00:00 GMT  
 E-mail formating.
Hi ppl.

Lets say I've an e-mail in this forma:

From tst3 Tue May 18 16:54:29 1999
Date: Tue, 18 May 1999 16:54:29 +0100 (BST)
From: User of Tst <tst3>

Content-Length: 6

blah blahb alh
blahblahblah blah blah blah
blah blahb alh
blahblahblah blah blah blah

<END>

How can I extract from this file only the body of the message?

Thanks for the help.
--
Miguel Manso



Sat, 03 Nov 2001 03:00:00 GMT  
 E-mail formating.
The body starts after the empty line after the header and spans for as
many lines as Content-Length field specifies.

The following script should do what you need:

/^Content-Length:/ {
  split( $0, arr, ":" );
  while( $0 !~ /^$/ ) getline;
  for( i=0; i<arr[2]; ++i ) {
    getline;
    print;
  }

Quote:
}

stasinos
Quote:

> Hi ppl.
> Lets say I've an e-mail in this forma:
> From tst3 Tue May 18 16:54:29 1999
> Date: Tue, 18 May 1999 16:54:29 +0100 (BST)
> From: User of Tst <tst3>

> Content-Length: 6
> blah blahb alh
> blahblahblah blah blah blah
> blah blahb alh
> blahblahblah blah blah blah
> <END>
> How can I extract from this file only the body of the message?
> Thanks for the help.
> --
> Miguel Manso




Sat, 03 Nov 2001 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Modula-2 compiler MOCKA: New mail/email/ftp address

2. Mail() Sending Email into the Ether

3. checking for errors after mail() hands email off to SMTP server

4. The email package and KLEZ mails

5. MS-Mail / Internet Mail / CC-Mail

6. Change e-mail / Cambio de e-mail / Changement d'e-mail

7. Launching the default email client with a specified email address

8. Email Expert Advice Needed- Problems decoding email from Korea

9. Topica Email List Directory A very active email list for Win32Forth

10. Lost email formatting Email !

11. 7/8 bit email (Was: Re: OT: Uitgelijnde email verzenden)

12. email.Message question. including email attachments

 

 
Powered by phpBB® Forum Software