Jump to content

Recommended Posts

Posted

Hy ..

 

i want to download all 10 minutes emails from mailserver....

 

WHERE is the best way to store this function?

Is the TuniThreadTimer the right thing?

Where should i store the Timer?

 

 

 

 

i want to download mails.... save them on disk (subfolder /mails) .. create a database entry .. and if the user wants to see a mail - i use a tuniHTMLFrame for displaying it..

 

i store the html-Mails with filename "html_....html

i store the textmails with filename "text_....txt

i store the attachements with filename "Anhang_...[suffix of content]

 

if someone has a better idea - please let me know :-)

 

 

 

for the Maildownload i will use this old code i wrote with Delphi7 ;-) :


interface


uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, IdContext, IdBaseComponent, IdComponent, IdCustomTCPServer,
  IdTCPServer, IdCmdTCPServer, IdExplicitTLSClientServerBase, IdPOP3Server,
  Buttons, IdTCPConnection, IdTCPClient, IdMessageClient, IdPOP3, ComCtrls,
  IdMessage, StdCtrls, IdMessageCoder, IdMessageCoderMIME,IdText ,IdAttachment,
  IdIOHandler, IdIOHandlerStream, IdIOHandlerSocket, IdIOHandlerStack,
  IdSSL, IdSSLOpenSSL;


type
  TForm1 = class(TForm)
    SpeedButton1: TSpeedButton;
    POP: TIdPOP3;
    msg: TIdMessage;
    Memo1: TMemo;
    IdSSLIOHandlerSocketOpenSSL1: TIdSSLIOHandlerSocketOpenSSL;
    procedure SpeedButton1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;


var
  Form1: TForm1;


implementation


{$R *.dfm}


procedure TForm1.SpeedButton1Click(Sender: TObject);
var MailCount,Mailgroesse,intIndex :Integer;
    itm:TListItem;
    i:integer;
    s:string;
begin


      POP.Host := 'pop.1und1.de';
      POP.Port := 995;
      POP.Username := 'xxxxx';
      POP.Password := 'yyyyyy';
      POP.Connect;


      memo1.Lines.Append(' .. erzeuge Verbindung zum POP Server....');
      
      MailCount := POP.CheckMessages;




      if MailCount = 0 then memo1.Lines.Append('Keine neuen Mails vorhanden...');


      if MailCount >0 then
      begin


          for intIndex := 1 to MailCount do
          begin
            msg.Clear;
            pop.Retrieve(intIndex, Msg);
            memo1.Lines.Append('......'+inttostr(intIndex));
            memo1.Lines.Append('**************************');
            memo1.Lines.Append('Von:            '+Msg.From.Text);
            memo1.Lines.Append('Antwortadresse: '+msg.from.Address );
            memo1.Lines.Append('Betreff:        '+Msg.Subject);
            memo1.Lines.Append('Priorität:      '+inttostr(ord(Msg.Priority)));
            memo1.Lines.Append('Datum:          '+datetostr(Msg.Date));
            memo1.Lines.Append('Uhrzeit:        '+TimeTostr(Msg.Date));
            memo1.Lines.Append('Mime-Type:      '+msg.AttachmentEncoding);
            memo1.Lines.Append('Content-Type:   '+msg.ContentType);


            memo1.Lines.Append('MIMEBoundary:   '+inttostr(msg.MIMEBoundary.Count));
            if msg.IsMsgSinglePartMime  then  memo1.Lines.Append('IsMsgSinglePartMime');
            if msg.IsEncoded            then  memo1.Lines.Append('IsEncoded');
            if msg.IsMsgSinglePartMime  then  memo1.Lines.Append('IsMsgSinglePartMime');
            if msg.NoEncode             then  memo1.Lines.Append('NoEncode');
            
            memo1.Lines.Append('------------------------------------------');




            
                //Anhang
                for i := 0 to Msg.MessageParts.Count-1 do begin
                  if Msg.MessageParts.Items[i] is tIdAttachment then
                      begin
                        s := (Msg.MessageParts.Items[i] as tIdAttachment).Filename;
                        memo1.Lines.Append('Anhang:          '+s);
                       (Msg.MessageParts.Items[i] as tIdAttachment).savetofile(ExtractFilePath(Application.ExeName) +'/Mails/Anhang_' + IntToStr(intIndex) +s);
                      end;
                end;




                // HTML Mail
                if msg.MessageParts.Count > 0 then
                begin
                memo1.Lines.Add('HTML-Mail:');
                for i := 0 to Msg.MessageParts.Count-1 do begin
                    if Msg.MessageParts.Items[i] is TIdText then
                     begin
                      //memo1.Lines.AddStrings(TIdText(Msg.MessageParts.Items[i]).Body);
                      TIdText(Msg.MessageParts.Items[i]).Body.SaveToFile(ExtractFilePath(Application.ExeName) +'/Mails/html_' + IntToStr(intIndex) + '.html');
                     end;
                end;
                end;




                // Text Mail
                if msg.ContentType = 'text/plain' then
                begin
                memo1.Lines.Add('TXT-Mail:');
                  //memo1.Lines.AddStrings(msg.body);
                  Msg.Body.SaveToFile(ExtractFilePath(Application.ExeName) +'/Mails/text_' + IntToStr(intIndex) + '.txt');
                end;






            memo1.Lines.Append('------------------------------------------');
            memo1.Lines.Append('');
            memo1.Lines.Append('');
            memo1.Lines.Append('');


            pop.Delete(intIndex);   // Löscht die aktuelle Mail !!!!
            end;
      end;
      POP.Disconnect;






end;


end.

 

Posted

.. Hi Gerhard...

 

you wrote:  "to view and write eMails...   you use UniGui .."

 

What do you use for display? .. UniHTMLframe???

 

Because i have problems if i show a Mail in a form containing a uniHTML-Frame ... the css of the emails chages the layout of my unigui-application ..

 

please have a look at: http://forums.unigui.com/index.php?/topic/8488-displaying-email%C2%B4s-changes-my-unidbgrid/

 

i solved the problem - but very crazy ;-)

 

 

 

 

P.S.:

 

now i use a service for downloading mails ... my Postng: http://www.delphipraxis.net/192647-email-downloader-service.html

 

do you know if somewhere ist a example-code, demo-code or something else online of a solution for:

 

pop without ssl

pop with ssl

imap

ect..

 

i just have the pop3 solution ..

 

Thanx for sugestions

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...