Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

_ Reading an original E-mail file

Posted on 1998-10-30
10
Medium Priority
?
183 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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 320 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
 

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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
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 course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses

604 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