Solved

Using Imap4

Posted on 2004-08-15
6
849 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
[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
  • 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
Technology Partners: 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!

 
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

Enroll in May's Course of the Month

May’s Course of the Month is now available! Experts Exchange’s Premium Members and Team Accounts have access to a complimentary course each month as part of their membership—an extra way to increase training and boost professional development.

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…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

737 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