Solved

Using Imap4

Posted on 2004-08-15
6
850 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
 

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
Industry Leaders: 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

[Webinar] Learn How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

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

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
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…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…

726 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