Solved

_ TPOP component

Posted on 1998-12-31
25
177 Views
Last Modified: 2012-05-04
Hi. What should I do if I want to read a local e-mail file with TPOP component without been connected.

Or Is there any site or document that explains the TPOP.

what should I add before
TPOP.GetDoc('c:\e-mail.eml', String1, String2);

?

Happy New Year
0
Comment
Question by:Wein
  • 12
  • 11
  • 2
25 Comments
 
LVL 8

Expert Comment

by:ZifNab
ID: 1353955
Hi Wein,

sorry I don't know... I don't use these components, I use the cardware of F.Piette. I find them much easier and you can have lot's of free help. Look for yourself if your interested : http://www.rtfm.be/fpiette/indexuk.htm. By the way, these components or not ActiveX or anything like that, so you don't have to install extra dll's.

Zif.
0
 
LVL 17

Expert Comment

by:inthe
ID: 1353956
i dont know what pop components you have but i can do this:

if POP1.State = prcDisConnected then
TPOP.GetDoc('c:\e-mail.eml', String1, String2);

Regards Barry
B.T.W if this dont work i suggest go with ZifNab's url they are the best to use and easiest
0
 
LVL 17

Expert Comment

by:inthe
ID: 1353957
Whoops Typo

if POP1.State = prcDisConnected then
POP1.GetDoc('c:\e-mail.eml', String1, String2);
0
 

Author Comment

by:Wein
ID: 1353958
Yeah. The Component of F. Piette is pretty good, but what do you do when there's an attached part? I mean, it's binary. And is there a way to separate it from the message and save it or view it as an associated file.
0
 
LVL 8

Expert Comment

by:ZifNab
ID: 1353959
I once started to program this. I used the Mime-component for it and then just copied the attached documents to there respective file name, etc.
0
 

Author Comment

by:Wein
ID: 1353960
Can you tell me more about it.

About the code and stuff...
0
 

Author Comment

by:Wein
ID: 1353961
Where to start separating the attached part?

and if there 's more than one file..
0
 
LVL 8

Expert Comment

by:ZifNab
ID: 1353962
I'll send you the source tomorrow.
0
 
LVL 8

Expert Comment

by:ZifNab
ID: 1353963
Hi Wein,

here is the code.

You simply put the mail to the mimedecode component. If the Filename contains the right file I start writing it to file. The whole mail is checked, so all attached files are looked at.

Forget Abort. I enhanced the component with this function. Maybe F. Piette someday will insert it in his component, I don't know.

I must say, I never fully tested this component. It was just something I tried out at my work. Never finished it properly.

procedure TfTransfer.MimeDecodePartHeaderEnd(Sender: TObject);
var FileExt : String;
    FileNr  : Integer;
begin
 FIsQCFile := False;
 if MimeDecode.PartFileName <> '' then begin
  FileExt := ExtractFileExt(MimeDecode.PartFileName);
  try
   FileNr := StrToInt(Copy(FileExt,2,Length(FileExt)));
  except
   on E:EConvertError do FileNr:=-1;
  end;
  if (FileNr >= 0) and (FileNr <= 999) then begin
   FIsQCFile := True;
   FQCFileDelete := True;
  end
   {else MimeDecode.Abort := true;}
 end;
end;

procedure TfTransfer.MimeDecodePartLine(Sender: TObject; Data: PChar;
  DataLen: Integer);
begin
 Application.ProcessMessages;
 if FIsQCFile then
  try
   FQCFileStream.WriteBuffer(Data^,DataLen);
   If MimeDecode.PartCharset = '"us-ascii"' then
    FQCFileStream.WriteBuffer(#13#10,2);      
  except
   FQCFileStream.Free;
   ShowCommand('$ERROR$ Stream');
  end;
end;

procedure TfTransfer.MimeDecodePartBegin(Sender: TObject);
begin
 if FIsQCFile then begin
   ShowCommand('+Start decoding '+MimeDecode.PartFileName+'...');
   try
    FQCFileStream := TFileStream.Create(FDir_Local+MimeDecode.PartFileName, fmCreate);
   except
    FQCFileStream.Free;
    ShowCommand('$ERROR$ Stream');
   end;
 end;
end;

procedure TfTransfer.MimeDecodePartEnd(Sender: TObject);
begin
 If FIsQCFile then begin
  ShowCommand('+Decoding ended.');
  FIsQCFile := False;
  FQCFileStream.Free;
 end;
end;

procedure TfTransfer.MimeDecodeAbort(Sender: TObject);
begin
 ShowCommand('Decoding aborted!');
end;

I see that the MimeDecode component has some changes (got a message through his mail list)

Regards, Zif.
0
 

Author Comment

by:Wein
ID: 1353964
Thanx for that

By the way, if the character set is other than us-ascii, what do I do?

And can you give me a list of Internet Explorer Character set?

thanx.
0
 
LVL 8

Expert Comment

by:ZifNab
ID: 1353965
Hi Wein, I make a difference in this ascii, because I needed to add CRLF add the end of each line, otherwise I would have one long sentence.... If type is binary then you offcourse don't need to add CRLF, because then the result is not what you expect. Then you got a corrupt binary file :-).

What do you mean with IE Char set?

Zif.
0
 

Author Comment

by:Wein
ID: 1353966
If the charset is other than us-ascii... ?
What should I do for displaying, let say, a Chinese text of BIG-5?

Well, I want to know if the MIME Component does the DATE converting.

You know, after a date, there's a -0800 or something for the GMT.
0
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).

 

Author Comment

by:Wein
ID: 1353967
I think the version I got has something like DestStream.

Is it what I need to extract the attached file?

The code you gave me seems logical and I tried to test it.
But there are errors because things have changed. Well, I'll figure it out by myself this part.

Thanx for the code.

Can you answer for my questions above? (date...)

WEiN

0
 

Author Comment

by:Wein
ID: 1353968
Oops, I've made a mistake about deststream, just ignore it.

Well, I read the document that comes with the component. It doesn't convert the date.

So can you tell me how to convert it to a variable of TDatetime calibrated with its GMT?

And, last question, if I get a string like this:
stringA : qna@experts-exchange.com (Experts Exchange)
or
stringB : "Wein Chien" <trustno1wei@hotmail.com>

how can I separate things in String A, B with one same code?

Result :
stringAname : 'Experts Exchange'
stringAaddress : 'qna@experts-exchange.com'
stringBname : 'Wein Chien'
stringBaddress : 'trustno1wei@hotmail.com'

N.B. I want to get rid of the quote or any character that surround it. ( & ); < & >; or anything.


0
 
LVL 8

Expert Comment

by:ZifNab
ID: 1353969
Hi Wain,

as I said before I just played with these components, but I found out that they were robuust and good.

About 1.  Believe it is answered here already some time ago, and I believe also in the A&Q montly list at F.Piette. (you can search for it from here :

About 2. I guess, you first have to make a code to find the stringpart with @. This will give you the stringBaddress (always). Then, if another part (seperated by a space) is available then this will be most likely stringAname. After that you just look for specific container characters (like <,>, (,)) and remove these from the strings.

Regards, Zif.
0
 
LVL 8

Expert Comment

by:ZifNab
ID: 1353970
forgot to give the list : http://www.rtfm.be/fpiette/supportuk.htm
0
 

Author Comment

by:Wein
ID: 1353971
Thanx, but what is the command to get things arround the @ ?

Can you explain more technically about 2 ?

Thanx.
0
 
LVL 8

Expert Comment

by:ZifNab
ID: 1353972
This code need offcourse a lot of improvements! but it gives you an idea :

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls;

type
  TForm1 = class(TForm)
    Edit1: TEdit;
    Label1: TLabel;
    Label2: TLabel;
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.Button1Click(Sender: TObject);
var WorkStr : string;
    Straddress, Strname : Shortstring;
    PosSpace : integer;
    PosEmail : integer;
    PosBegin, PosEnd : integer;

begin
 WorkStr := Edit1.Text;
 // simplification of problem!
 PosEmail := Pos('@',WorkStr);
 PosBegin := PosEmail;
 PosEnd := PosEmail;
 while (WorkStr[PosBegin] <> ' ') and (PosBegin <> 0) do Dec(PosBegin);
 while (WorkStr[PosEnd] <> ' ') and (PosEnd <> Length(WorkStr)) do Inc(PosEnd);
 StrAddress := Copy(WorkStr,PosBegin,PosEnd-PosBegin);
 Delete(WorkStr, PosBegin+1, PosEnd-PosBegin);
 StrName := WorkStr;
 // Following not nessecarely needed.
 StrAddress := TrimLeft(StrAddress);
 StrAddress := TrimRight(StrAddress);
 StrName := TrimLeft(StrName);
 StrName := TrimRight(StrName);
 // Following code, surely needs improvement!
 // you can check :
 If (StrName[1] IN ['"','(','<','[']) and (StrName[Length(StrName)] IN ['"',')','>',']']) then
  StrName := Copy(StrName,2,Length(StrName)-2);
 // or
  if (not(StrAddress[1] IN ['0'..'9', 'A'..'Z', 'a'..'z', '@'])) and
   (not(StrAddress[Length(StrAddress)] IN ['0'..'9', 'A'..'Z', 'a'..'z', '@'])) then
    StrAddress := Copy(StrAddress,2, Length(StrAddress)-2) ;


 // I think that you can find the legal characters in RFC documents (to improve above code)!!

  Label1.Caption := StrName;
  Label2.Caption := StrAddress;
end;

end.
0
 

Author Comment

by:Wein
ID: 1353973
Yeah, what is RFC?

In the text of Piette, the word keeps coming back.

Is it the manual of Delphi?

Which one?

Because I have the standard version.
0
 
LVL 8

Expert Comment

by:ZifNab
ID: 1353974
Hi Wein,

RFC (Request for Comments) describes the protocols used by Ftp, POP, .... how the mails have to be written, etc...

See : http://intranet.www-kr.org/RFC/index.html

Search for the RFC of POP and from there you know what I mean.

Regards, Zif.


0
 
LVL 8

Expert Comment

by:ZifNab
ID: 1353975
Hi Wein,

how is it going?

Zif.
0
 

Author Comment

by:Wein
ID: 1353976
I think it will work.

I'm reading them.

I'm writing codes that looks similar to yours.

Do you want to end this questions and get the points ?

Or I can suspend this question. In the case I will have questions for you.

HEHE

I think the answers you gave to me are valuable !!!
0
 
LVL 8

Accepted Solution

by:
ZifNab earned 100 total points
ID: 1353977
Glad to hear that the comments I gave were helpfull. I answer this question (OK?), but you can still ask questions under this thread.
0
 

Author Comment

by:Wein
ID: 1353978
Well, it worked ! I've finally done it.

I changed a bit what you gave me. Some lines were wrong... But without them to guide me, My codes won't work. Thanx

So, I have two small easy questions, and I think, that's all.

1.
I don't understand things with pointer, @operator ...
you know, when you have a variable named MyVariable,
What are the uses and the meanings for putting:
MyVariable^
and @MyVariable ?

Can you explain this ? And it will be better if you can show me the different results I can get with them.

2.
A)I use to use the component TOpenDialogs..... TDialogs...,
But they are not the object inside the COMCTL32.DLL of Windows.

They are written by Delphi.

Is it possible to call the Dialogs of COMCTL32.DLL ?
The reason is because I have Delphi 3 running in Windows 98.
There are new features in W98. However, D3 was written in the time of W95. So, I think it will be just great if I can access the Dialogs directly from the Microsoft's DLL.

B)In the Dialog components, there is no "folder-selecting Dialog"
I have used some 3rd-party components. I want to know if there is an API call for this Dialog.

You can see this Dialog in many places of Windows (95 ~ 98 and NT 4).

Well Thanx
0
 

Author Comment

by:Wein
ID: 1353979
That was the main thing I have changed :
.
if MimeDecode1.PartDisposition = 'attachment' then
.

WEiN
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

747 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

13 Experts available now in Live!

Get 1:1 Help Now