Solved

_ Reading an original E-mail file

Posted on 1998-10-30
10
146 Views
Last Modified: 2010-04-06
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
0
Comment
Question by:Wein
  • 6
  • 4
10 Comments
 

Author Comment

by:Wein
ID: 1345105
Edited text of question
0
 
LVL 4

Expert Comment

by:dwwang
ID: 1345106
Why not read them directly from pop3 server using the pop3 component in Delphi?
0
 

Author Comment

by:Wein
ID: 1345107
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
0
 

Author Comment

by:Wein
ID: 1345108
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
0
 
LVL 4

Accepted Solution

by:
dwwang earned 80 total points
ID: 1345109
TStringList has the method LoadFromFile, you can simply call it and each line in the file will become a string in the StringList, then you can traverse the list to find the information necessary to seperate the body of the e-mail, such as "To:"/"From:" or some other words.
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:Wein
ID: 1345110
Can you give some source code.

concrete source code?

And do you know how to format the DATE section?
0
 
LVL 4

Expert Comment

by:dwwang
ID: 1345111
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?
0
 

Author Comment

by:Wein
ID: 1345112
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.
0
 
LVL 4

Expert Comment

by:dwwang
ID: 1345113
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.
0
 

Author Comment

by:Wein
ID: 1345114
Well, I haven't test it but Pos was exactly the function I was searching for.

Thanx dwwang !!!

Wein
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Wininet read php file from internet issue 6 83
build html 5 client that connect to indy Tidtcpserver 3 357
Delphi : could not find program, '...exe' 2 149
Printing problem 2 81
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now