Solved

_ TPOP component

Posted on 1998-12-31
25
182 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
[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
  • 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
Industry Leaders: 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: 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
 

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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

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…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

752 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