Solved

Using Imap4

Posted on 2004-08-15
6
842 Views
Last Modified: 2008-01-09
Hi, I have been developing an email client for a while. So far it is capabale of receiving/rettrieving pop3 mail and sending mail via SMTP. I am at the point where I now want to make my application able to fetch webmail as well (e.g. from yahoo mail & hotmail). I understand that this can be done with the IMAP indy component ?? Can anyone tell me if this assumption is correct...and if not then how can I do this? Also wondering if anyone knows about any examples of how to use this tidIMAP component.. Cheers. R
0
Comment
Question by:Runelurenavn
  • 3
  • 3
6 Comments
 
LVL 12

Expert Comment

by:esoftbg
Comment Utility
0
 

Author Comment

by:Runelurenavn
Comment Utility
Hi, Thanks for the links. Unfortunately I can only view the questions, not the answers (as far as I am able to tell anyway). Is there another way I can access this information? R
0
 
LVL 12

Expert Comment

by:esoftbg
Comment Utility
Here is the accepted answer for the first link above :

ClientType property is set up to ctNonBlocking by default.

unit Unit1;

// IMAP application demo:

interface

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

type
  TForm1 = class(TForm)
    ClientSocket1: TClientSocket;
    Button1: TButton;
    Label1: TLabel;
    Label2: TLabel;
    Memo1: TMemo;
    Label3: TLabel;
    Edit1: TEdit;
    Label4: TLabel;
    Edit2: TEdit;
    Label5: TLabel;
    Edit3: TEdit;
    Timer1: TTimer;
    procedure ClientSocket1Read(Sender: TObject; Socket: TCustomWinSocket);
    procedure Button1Click(Sender: TObject);
    procedure EditChange(Sender: TObject);
    procedure Timer1Timer(Sender: TObject);
  private
    Response,               // Server response strings
    RequestTag: String;     // Client request tag
    Time: Integer;
  end;

const
  TimeOut = 100;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.ClientSocket1Read(Sender: TObject;
  Socket: TCustomWinSocket);
var
  Number, S: String;
  Lines: TStringList;
  I: Integer;
begin
  Response := Response + Socket.ReceiveText;
  // Verify if the response is complete
  if (Response[Length(Response)] in [#10, #13]) then
  begin
    if (RequestTag <> '') then if (Pos(RequestTag, Response) <= 0) then Exit;
    Memo1.Lines.Add(Response);
    Time := 0;
    // Process response if no errors
    if Pos('OK', Response) > 0 then
    begin
      if RequestTag = '' then // Server prompt
      begin
        // Send Login command
        RequestTag := 'A001';
        Socket.SendText('A001 LOGIN ' + Edit2.Text + ' ' + Edit3.Text + #10#13);
      end else if RequestTag = 'A001' then // Login completed
      begin
        RequestTag := 'A142';
        Socket.SendText('A142 SELECT INBOX'#10#13);
      end else
      begin      // Select completed
        // Close socket
        ClientSocket1.Active := false;
        Lines := TStringList.Create;
        try
          // Extract messages number from server responce
          Lines.Text := Response;
          for I := 0 to Lines.Count - 1 do
          begin
            s := LowerCase(Lines.Strings[I]);
            if (Pos('exists', s) > 0) then
            begin
              Number := '';
              while (Lines.Strings[I][Length(Number) + 3] in ['0' .. '9']) do
               Number := Number + Lines.Strings[I][Length(Number) + 3];
              // Display number
              Label2.Caption := Number;
              Break;
            end;
          end;
        finally
          Lines.Free
        end;
        ClientSocket1.Active := false;
        Timer1.Enabled := false;
      end;
    end else
    begin
      Label2.Caption := 'Error';
      ClientSocket1.Active := false;
      Timer1.Enabled := false;
    end;
    Response := '';
  end;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  ClientSocket1.Address := Edit1.Text;
  ClientSocket1.Active := true;
  Response := '';
  RequestTag := '';
  Memo1.Clear;
  Time := 0;
  Timer1.Enabled := true;
end;

procedure TForm1.EditChange(Sender: TObject);
begin
  Button1.Enabled := (Edit1.Text <> '') and (Edit2.Text <> '') and
      (Edit3.Text <> '');
end;

procedure TForm1.Timer1Timer(Sender: TObject);
begin
  Inc(Time);
  if Time > TimeOut then
  begin
    ClientSocket1.Active := false;
    Label2.Caption := 'error';
    Timer1.Enabled := false;
  end;
end;

end.

This has an errors and timeouts processing.

Complete Delphi 6 source with compiled executable I placed here: http://www.serge.dsip.net/downloads/IMAPdemo.zip .

P. S. Delphi 7 comes with built in IMAP client component (Indy tab).
0
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 
LVL 12

Accepted Solution

by:
esoftbg earned 500 total points
Comment Utility
Here is the accepted answer for the second link above :

Download the Blue HTTPMail Proxy from http://prdownloads.sourceforge.net/bhttpmail/HttpMailProxy-Win32Bin-v0.02.1.zip?

This app works as a service so it must be on NT, Win2K or WinXP.

There is also HotPOP3 downloadable from http://prdownloads.sourceforge.net/hotpop3/pop3httpproxy.0.0.1.zip?download
that works on any flavor of Windows.

After installing one of these proxies, setup Indy or NMSMTP to access SMTP on localhost or 127.0.0.1 and set your username
and password. All there is to it.
0
 

Author Comment

by:Runelurenavn
Comment Utility
Hi & thanks for the comments. I am still struggling here...maybe I should have specified that I am using Delphi 7 and the IMAP component that comes with it. So I am not sure if I can use the socket code as a guide?
My program also needs to be compatible with win versions back to (and including) 98..
Just wondering if the hotpop3 download will enable me to retrieve any kind of mail via SMTP??
Thanks. R
0
 

Author Comment

by:Runelurenavn
Comment Utility
Hi, I have been trying to use the Blue HTTPMail Proxy program to get this going - and it seems to be the best way to go as esoftbg suggested. Just took me a while to realize :)
Now I am stuck on how to use this Blue HTTPMail Proxy program with D7. I have tried connecting to it using idIMAP and idPOP3 components, but it doesn't seem to work....can someone guide me trough this???
I have increased the points since this has been more involved than I anticipated :)
R
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

728 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

14 Experts available now in Live!

Get 1:1 Help Now