Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 196
  • Last Modified:

_ TPOP component

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
Wein
Asked:
Wein
  • 12
  • 11
  • 2
1 Solution
 
ZifNabCommented:
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
 
intheCommented:
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
 
intheCommented:
Whoops Typo

if POP1.State = prcDisConnected then
POP1.GetDoc('c:\e-mail.eml', String1, String2);
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!

 
WeinAuthor Commented:
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
 
ZifNabCommented:
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
 
WeinAuthor Commented:
Can you tell me more about it.

About the code and stuff...
0
 
WeinAuthor Commented:
Where to start separating the attached part?

and if there 's more than one file..
0
 
ZifNabCommented:
I'll send you the source tomorrow.
0
 
ZifNabCommented:
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
 
WeinAuthor Commented:
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
 
ZifNabCommented:
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
 
WeinAuthor Commented:
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
 
WeinAuthor Commented:
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
 
WeinAuthor Commented:
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
 
ZifNabCommented:
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
 
ZifNabCommented:
forgot to give the list : http://www.rtfm.be/fpiette/supportuk.htm
0
 
WeinAuthor Commented:
Thanx, but what is the command to get things arround the @ ?

Can you explain more technically about 2 ?

Thanx.
0
 
ZifNabCommented:
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
 
WeinAuthor Commented:
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
 
ZifNabCommented:
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
 
ZifNabCommented:
Hi Wein,

how is it going?

Zif.
0
 
WeinAuthor Commented:
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
 
ZifNabCommented:
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
 
WeinAuthor Commented:
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
 
WeinAuthor Commented:
That was the main thing I have changed :
.
if MimeDecode1.PartDisposition = 'attachment' then
.

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!

  • 12
  • 11
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now