Link to home
Start Free TrialLog in
Avatar of Wein
Wein

asked on

_ Reading an original E-mail file

Hi. I want to manipulate Email.

When I save an e-mail as a file (*.eml) from Outlook, I can get a plain ASCII text file. I would like to manipulate it with my program which separates the header (subjet...sender...)
and the message itself.

I also want the ability to get the subject, the sender, the MIME, the Date separetely... (for a Label.caption each of them)

In the date, there's something like -0004. How am I suppose to format it to make it become a everybody readable DATE.

I would like to have a clear explanation.

N.B. I want all the data to be accessible from a Tstrings(memo, list...)

Thank you.

Wein
trustno1wei@hotmail.com
10-30-98
Avatar of Wein
Wein

ASKER

Edited text of question
Why not read them directly from pop3 server using the pop3 component in Delphi?
Avatar of Wein

ASKER

Oh i'll try to read it from a POP3 component.

Thanx.

But I still need to know the code for separating a file into different sections.

I have to do that with News (*.nws) files and other ASCII files.

Suppose this (same pattern as news and email files):

============start of file========
My name : Wein. XfDFSD
Birth : 123456
From : r403536

this is where is the message............

FSGSGDS
dHSDHFDH

sdHDHDHDH

============end of file========

I want to split this file into a part with the message only and other parts with name, birth... separately. So I can put them to any string field or something similar.

How can we separate it? there's no comma, semi-colon. And how can it distinguish "CHANGE LINE" character when it's in the header or in the message itself?
Well. That's it.

Any answer will be appreciate.

Wein
Avatar of Wein

ASKER

Oh i'll try to read it from a POP3 component.

Thanx.

But I still need to know the code for separating a file into different sections.

I have to do that with News (*.nws) files and other ASCII files.

Suppose this (same pattern as news and email files):

============start of file========
My name : Wein. XfDFSD
Birth : 123456
From : r403536

this is where is the message............

FSGSGDS
dHSDHFDH

sdHDHDHDH

============end of file========

I want to split this file into a part with the message only and other parts with name, birth... separately. So I can put them to any string field or something similar.

How can we separate it? there's no comma, semi-colon. And how can it distinguish "CHANGE LINE" character when it's in the header or in the message itself?
Well. That's it.

Any answer will be appreciate.

Wein
ASKER CERTIFIED SOLUTION
Avatar of dwwang
dwwang

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Wein

ASKER

Can you give some source code.

concrete source code?

And do you know how to format the DATE section?
sl:TStringList;

sl:TStringList.Create;
sl.LoadFromFile('MyMail.eml')

while i<sl.count do

begin
     if uppercase(Copy(sl.strings[i],1,5))='FROM:' then ......
     //you can put other processing here.
end;

and what special process do you need for the date section?
Avatar of Wein

ASKER

In the date, there's something like this:

Date: Tue, 20 Oct 1998 19:22:29 -0400

what means -0400?

i think it's the GMT code. but i want to format it so it's understandable.

Do you have the constant list?

==

And by the way.

the method you've provided can get the whole line about  "Wein Chien" <trustno1wei@hotmail.com>
of From: "Wein Chien" <trustno1wei@hotmail.com> ?

And then, for further information, if i want to have just the part included in < and >, how can i do it?

thanks.
The main solution is using Pos function, try to see the help.

With it you can find '+'/'-' in the date section, as well as '<'/'>' in the from/to section, then use the copy function to do what you need.

I think that should be enhough.
Avatar of Wein

ASKER

Well, I haven't test it but Pos was exactly the function I was searching for.

Thanx dwwang !!!

Wein