Solved

Using Imap4

Posted on 2004-08-15
6
844 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
ID: 11805008
0
 

Author Comment

by:Runelurenavn
ID: 11812552
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
ID: 11812801
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
Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

 
LVL 12

Accepted Solution

by:
esoftbg earned 500 total points
ID: 11812837
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
ID: 11827783
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
ID: 11997209
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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Virtuailstring tree compare node issue 14 116
FMX enumerated colours 2 98
How to load 2 images in same column in Delphi 2 45
update joined tables 2 45
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…
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…
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

774 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