Solved

_ Reading an original E-mail file

Posted on 1998-10-30
10
155 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
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!

 

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
 

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

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!

Question has a verified solution.

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

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

763 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