Solved

_ Reading an original E-mail file

Posted on 1998-10-30
10
142 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
Comment Utility
Edited text of question
0
 
LVL 4

Expert Comment

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

Author Comment

by:Wein
Comment Utility
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
Comment Utility
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
Comment Utility
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
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 

Author Comment

by:Wein
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
Well, I haven't test it but Pos was exactly the function I was searching for.

Thanx dwwang !!!

Wein
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
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…
This video discusses moving either the default database or any database to a new volume.
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

771 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

12 Experts available now in Live!

Get 1:1 Help Now