Question

Urgent POP3 to Listbox example 500 Points

Asked by: sfern

Hi all,

I need an example of a POP3 clien that will collect the mails and put them in a LISTBOX.
Now, the emails are going to be sent to me separated by a semicolon between each field.
If it's possible i would like the example on a button click procedure to execute.
As i need it ASAP, i'm giving 500 points for it.

Thanks

SFern

This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.

Subscribe now for full access to Experts Exchange and get

Instant Access to this Solution

  • Plus...
  • 30 Day FREE access, no risk, no obligation
  • Collaborate with the world's top tech experts
  • Unlimited access to our exclusive solution database
  • Never be left without tech help again

Subscribe Now

Asked On
2004-04-01 at 00:23:27ID20939705
Tags

example

Topic

Delphi Programming

Participating Experts
3
Points
500
Comments
19

Trusted by hundreds of thousands everyday for fast, accurate and reliable tech support.

  • "The time we save is the biggest benefit of Experts Exchange to Warner Bros. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange." Mike Kapnisakis, Warner Bros.
  • "Our team likes having a resource that is more secure than just using Google and most experts using this service really know their stuff. It's nice to look here first versus using Google." Dayna Sellner, Lockheed Martin
  • "Anytime that I've been stumped with a problem, 9 out of 10 times Experts Exchange has either the accepted solution or an open discussion of the potential solution to the problem." Kenny Red, eBay Inc.

See what Experts Exchange can do for you.

Got a question?

We've got the answer.

Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.

Screenshot of Experts Exchange Knowledgebase

Need individual assistance?

Our experts are ready to help.

If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.

Screenshot of Experts Exchange Knowledgebase

Want to learn from the best?

Read articles from industry experts.

Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.

Screenshot of an Article

Working on a long term project?

Store your work and research.

Save solutions to your questions, answers you’ve discovered through searching plus helpful articles in your personal knowledgebase for easy future access.

Screenshot of Experts Exchange Knowledgebase

Access the answers to your technology questions today.

Subscribe Now

30-day free trial. Register in 60 seconds.

What Makes Experts Exchange Unique?

Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Trusted by the world's most respected brands.

image of each brand's logo

Faithfully serving IT professionals since 1996.

Experts Exchange Logo

Try it out and discover for yourself.

Subscribe Now

30-day free trial. Register in 60 seconds.

Related Solutions

  1. listbox scrolling
    i need to retrieve 1 million records into my listbox in the sorted order.like if i select a letter 'k' I NEED to get all the records with 'K'. i THINK THERE are some restrictions with getting all the records into a VB listbox(256 at most). Pl suggest me an ANSWER asap. Tha...

Free Tech Articles

  1. WARNING: 5 Reasons why you should NEVER fix a computer for free.
    It is in our nature to love the puzzle. We are obsessed. The lot of us. We love puzzles. We love the challenge. We thrive on finding the answer. We hate disarray. It bothers us deep in our soul. W...
  2. SCCM OSD Basic troubleshooting
    SCCM 2007 OSD is a fantastic way to deploy operating systems, however, like most things SCCM issues can sometimes be difficult to resolve due to the sheer volume of logs to sift through and the dispe...
  3. Migrate Small Business Server 2003 to Exchange 2010 and Windows 2008 R2
    This guide is intended to provide step by step instructions on how to migrate from Small Business Server 2003 to Windows 2008 R2 with Exchange 2010. For this migration to work you will need the fo...
  4. Create a Win7 Gadget
    This article shows you how to create a simple "Gadget" -- a sort of mini-application supported by Windows 7 and Vista. Gadgets can be dropped anywhere on the desktop to provide instant information, ...
  5. Outlook continually prompting for username and password
    There have been a lot of questions recently regarding Outlook prompting for a username and password whilst using Exchange 2007. There are a few reasons why this would happen and I will try to cover t...
  6. Backup Exchange 2010 Information Store using Windows Backup
    There seems to be quite a lot of confusion around the ability to backup Exchange 2010 using the built in Windows Backup feature. This stems from the omission of this feature prior to Exchange 2007 s...

Cloud Class Webinars

  1. Avoiding Bugs in Microsoft Access
    Alison Balter takes and in-depth look at avoiding bugs in Access. In this webinar you will learn about using the immediate window to debug your applications, invoking the debugger, using breakpoints to troubleshoot, stepping through code, setting the next statement to execute, ...
  2. Top 10 Best New Features in Visio 2010
    Scott Helmers gives live demonstrations of the top 10 new features in Visio 2010. This webinar will teach you how to create compelling diagrams by adding shapes to the page with a single click, linking the shapes in a diagram to data in Excel (or SQL Server, or SharePoint), ...
  3. IT Consultant Business Secrets Revealed
    Michael Munger, Experts Exchange tech pro and IT consultant, pulls back the curtain on his very successful businesses and answers question on every IT consultant and business owner should know about. He shares secrets on what he did to solve the 5 most common problems in IT, ...
  4. Disaster Recovery and Business Continuity
    Quest CTO, Mike Billon, gives an overview of the steps involved in building a dunamic disaster recovery plan. Through case studies and an examination of software/hardware tooles for monitoring and testing, you'll gain a better understandin of where you are, where you want ...
  5. Organize Your Visio Diagrams with Containers and Lists
    Scott Helmers uses cross functional flowcharts, wireframe diagrams, data graphic legends and seating charts to teach you: how to ustilize all three new structured diagram components in Visio 2010, the best practices for organizeing shapes in previous version of Visio, how to organize ...
  6. How to Us Objects, Properties, Events and Methods in Microsoft Access
    Alison Dalter gives an in-depbth look at objects, properties, events and methods in Microsoft Access. In this webinar you will learn about using the object browser, referring to objects, working with properties and methods, working with object variables, understanding the ...

Join the Community

Give a Little. Get a Lot.

Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.

Join the Community

Answers

 

by: k4hvd77Posted on 2004-04-01 at 00:49:12ID: 10730460

Could you explain what do you mean with "collect the mails and put them in a LISTBOX" and "the emails are going to be sent to me separated by a semicolon between each field"

what do you whant to put in a Listbox?? Email Sender, Body, Subject!!??

 

by: mocartsPosted on 2004-04-01 at 00:49:42ID: 10730462

Hi SFern :)
what  you mean with "Now, the emails are going to be sent to me separated by a semicolon between each field."? do you need e-mail addresses collected in LISTBOX or email Subjects?
Can you explain what you need a bit more?

wbr, mo.

 

by: sfernPosted on 2004-04-01 at 02:55:04ID: 10731025

Well, i'm going to be sent and email with an ID, account no. etc on the body, this with be like 112;2344567;etc...i need to collect those email fields and separate them under individual headings on the listbox.

Sfern

 

by: mocartsPosted on 2004-04-01 at 04:01:38ID: 10731316

Hi
I have placed some sample App at http://www.grava.lv/files/pro/PopParse.zip
instead of LISTBOX we need to use ListView (to define columns) and I have used Indy Pop3 client component (you can download those components form http://www.indyproject.org/)

wbr, mo.

 

by: mokulePosted on 2004-04-01 at 04:21:44ID: 10731400

// provided Content-Type: text/plain


procedure TForm1.Button1Click(Sender: TObject);
begin
  if not IdPOP31.Connected then
    begin
    IdPOP31.Host := LabeledEdit1.Text;
    IdPOP31.Password := LabeledEdit2.Text;
    IdPOP31.Username := LabeledEdit3.Text;
    IdPOP31.Connect();
    end;
end;


procedure TForm1.Button3Click(Sender: TObject);
var
  idm: TIdMessage;
  mCount: integer;
  hc: integer;
  i: integer;
  j: integer;
  str: TStringList;
  li: TListItem;
  Line: string;
  Ptr: integer;
begin
  if IdPOP31.Connected then
    begin
    ListView1.Clear;
    str := TStringList.Create;
    mCount := IdPOP31.CheckMessages;
    idm :=TIdMessage.Create(Self);
    if mCount = 0 then
      begin
//      li := ListView1.Items.Add;
//      li.Caption := ' There is no messages ';
      end;
    for i := 1 to mCount do
      begin
//      li := ListView1.Items.Add;
//      li.Caption := '----------------------------';


      IdPOP31.Retrieve(i,idm);
      for j := 0 to idm.Body.Count-1 do
        begin
        Line := idm.Body[j];
        Ptr := Pos(';',Line);
        if Ptr > 0 then
          begin
          li := ListView1.Items.Add;
          li.Caption := Copy(Line,1,Ptr-1);
          Line := Copy(Line,Ptr+1,Length(Line));
          Ptr := Pos(';',Line);
          while Ptr > 0 do
            begin
            li.SubItems.Add(Copy(Line,1,Ptr-1));
            Line := Copy(Line,Ptr+1,Length(Line));
            Ptr := Pos(';',Line);
            end;
          if Length(Line) > 0 then
            begin
            li.SubItems.Add(Line);
            end;
          end
        else
//          li.Caption := 'Format error';
        end;

{
      IdPOP31.RetrieveRaw(i,str);
      for j := 0 to str.Count-1 do
        begin
        li := ListView1.Items.Add;
        li.Caption := str[j];
        end;
}

      end;
    idm.Free;
    str.Free;
    end;

end;

 

by: sfernPosted on 2004-04-01 at 05:13:53ID: 10731666

First of all thanks for your time but it still doesn't work.

1. mocarts, your's is only retreving 2 messages and only 2 fields but none from the body message, which are separated by semi-colons.

2. mokule, i tried yours and for some reason it's not working.

The emails that i would receive would look like this:

From: whoever@blablabla.com

Subject: whatever

Body: 1;1234567;Mr;Paul;Chingo

Now, the listview will have these headings:

ID, Account No.,Title, Firstname, Surname.

The text in the body would go under their corresponding listview columns, so in this example the listview would look like this:

ID  Account No.    Title  Firstname    Surname <--- Listview headers

1   1234567         Mr    Paul             Chingo


I hope that this will make it a bit clearer for you.

Thanks

SFern.

 

by: mokulePosted on 2004-04-01 at 05:32:43ID: 10731816

I presume that You place TListView on a Form.
And Inserted columns manually at design time.

    IdPOP31.Host := 'blablabla.com';
    IdPOP31.Password := 'your password';
    IdPOP31.Username := 'whoever@blablabla.com';
    IdPOP31.Connect();

This should be done first
Important: e-mail must be Content-Type: text/plain    !!!!
I've tested it. It absolutly works.

 

by: sfernPosted on 2004-04-01 at 05:35:24ID: 10731839

OK i'll try again.

Thanks

 

by: mokulePosted on 2004-04-01 at 05:40:50ID: 10731890

{ email body
Value1a;Value1b;Value1c;Value1d;Value1e
Value2a;Value2b;Value2c;Value2d;Value2e
Value3a;Value3b;Value3c;Value3d;Value3e
Value4a;Value4b;Value4c;Value4d;Value4e
Value5a;Value5b;Value5c;Value5d;Value5e
Value6a;Value6b;Value6c;Value6d;Value6e
}



unit MainPOP3;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ExtCtrls, IdBaseComponent, IdComponent,
  IdTCPConnection, IdTCPClient, IdMessageClient, IdPOP3, IdMessage,
  shellapi, ComCtrls;

type
  TForm1 = class(TForm)
    IdPOP31: TIdPOP3;
    Panel1: TPanel;
    LabeledEdit1: TLabeledEdit;
    LabeledEdit2: TLabeledEdit;
    LabeledEdit3: TLabeledEdit;
    Button2: TButton;
    Button1: TButton;
    Button3: TButton;
    ListView1: TListView;
    procedure Button1Click(Sender: TObject);
    procedure IdPOP31Connected(Sender: TObject);
    procedure IdPOP31Disconnected(Sender: TObject);
    procedure Button3Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
begin
  if not IdPOP31.Connected then
    begin
    IdPOP31.Host := LabeledEdit1.Text;
    IdPOP31.Password := LabeledEdit2.Text;
    IdPOP31.Username := LabeledEdit3.Text;
    IdPOP31.Connect();
    end;
end;

procedure TForm1.IdPOP31Connected(Sender: TObject);
begin
  Button2.Enabled := True;
  Button3.Enabled := True;
  Button1.Enabled := False;
end;

procedure TForm1.IdPOP31Disconnected(Sender: TObject);
begin
  Button2.Enabled := False;
  Button3.Enabled := False;
  Button1.Enabled := True;
end;


// provided Content-Type: text/plain

procedure TForm1.Button3Click(Sender: TObject);
var
  idm: TIdMessage;
  mCount: integer;
  hc: integer;
  i: integer;
  j: integer;
  str: TStringList;
  li: TListItem;
  Line: string;
  Ptr: integer;
begin
  if IdPOP31.Connected then
    begin
    ListView1.Clear;
    str := TStringList.Create;
    mCount := IdPOP31.CheckMessages;
    idm :=TIdMessage.Create(Self);
    if mCount = 0 then
      begin
//      li := ListView1.Items.Add;
//      li.Caption := ' There is no messages ';
      end;
    for i := 1 to mCount do
      begin
//      li := ListView1.Items.Add;
//      li.Caption := '----------------------------';


      IdPOP31.Retrieve(i,idm);
      for j := 0 to idm.Body.Count-1 do
        begin
        Line := idm.Body[j];
        Ptr := Pos(';',Line);
        if Ptr > 0 then
          begin
          li := ListView1.Items.Add;
          li.Caption := Copy(Line,1,Ptr-1);
          Line := Copy(Line,Ptr+1,Length(Line));
          Ptr := Pos(';',Line);
          while Ptr > 0 do
            begin
            li.SubItems.Add(Copy(Line,1,Ptr-1));
            Line := Copy(Line,Ptr+1,Length(Line));
            Ptr := Pos(';',Line);
            end;
          if Length(Line) > 0 then
            begin
            li.SubItems.Add(Line);
            end;
          end
        else
//          li.Caption := 'Format error';
        end;

{
      IdPOP31.RetrieveRaw(i,str);
      for j := 0 to str.Count-1 do
        begin
        li := ListView1.Items.Add;
        li.Caption := str[j];
        end;
}

      end;
    idm.Free;
    str.Free;
    end;

end;

procedure TForm1.Button2Click(Sender: TObject);
begin
  if IdPOP31.Connected then
    IdPOP31.Disconnect;
end;

procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
  if IdPOP31.Connected then
    IdPOP31.Disconnect;
end;

end.

//-------------------------------------- DFM

object Form1: TForm1
  Left = 223
  Top = 122
  Width = 544
  Height = 445
  Caption = 'Form1'
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -11
  Font.Name = 'MS Sans Serif'
  Font.Style = []
  OldCreateOrder = False
  OnClose = FormClose
  PixelsPerInch = 96
  TextHeight = 13
  object Panel1: TPanel
    Left = 0
    Top = 0
    Width = 536
    Height = 89
    Align = alTop
    TabOrder = 0
    object LabeledEdit1: TLabeledEdit
      Left = 8
      Top = 24
      Width = 145
      Height = 21
      EditLabel.Width = 22
      EditLabel.Height = 13
      EditLabel.Caption = 'Host'
      TabOrder = 0
    end
    object LabeledEdit2: TLabeledEdit
      Left = 176
      Top = 24
      Width = 121
      Height = 21
      EditLabel.Width = 46
      EditLabel.Height = 13
      EditLabel.Caption = 'Password'
      TabOrder = 1
    end
    object LabeledEdit3: TLabeledEdit
      Left = 320
      Top = 24
      Width = 177
      Height = 21
      EditLabel.Width = 22
      EditLabel.Height = 13
      EditLabel.Caption = 'User'
      TabOrder = 2
    end
    object Button2: TButton
      Left = 104
      Top = 56
      Width = 75
      Height = 25
      Caption = 'Disconnect'
      Enabled = False
      TabOrder = 3
      OnClick = Button2Click
    end
    object Button1: TButton
      Left = 8
      Top = 56
      Width = 75
      Height = 25
      Caption = 'Connect'
      TabOrder = 4
      OnClick = Button1Click
    end
    object Button3: TButton
      Left = 200
      Top = 56
      Width = 75
      Height = 25
      Caption = 'Retrieve'
      Enabled = False
      TabOrder = 5
      OnClick = Button3Click
    end
  end
  object ListView1: TListView
    Left = 0
    Top = 89
    Width = 536
    Height = 322
    Align = alClient
    Columns = <
      item
        Caption = '1'
      end
      item
        Caption = '2'
      end
      item
        Caption = '3'
      end
      item
        Caption = '4'
      end
      item
        Caption = '5'
      end>
    TabOrder = 1
    ViewStyle = vsReport
  end
  object IdPOP31: TIdPOP3
    MaxLineAction = maException
    ReadTimeout = 0
    OnDisconnected = IdPOP31Disconnected
    Host = 'abak.win.pl'
    OnConnected = IdPOP31Connected
    Left = 304
    Top = 56
  end
end

 

by: sfernPosted on 2004-04-01 at 06:01:29ID: 10732063

I've sent plain text messages but it doesn't retrieve any at all and i know that they are there :(

When i'm i doing wrong then, it's not working?


 

by: sfernPosted on 2004-04-01 at 06:10:21ID: 10732140

Would it be possible for me to download the source itself from you, because i must be doing something wrong here.

Thanks

sfern

 

by: mokulePosted on 2004-04-01 at 06:16:50ID: 10732201

I've posted all src pas file and dfm file. Didn't it work?
Send me e-mail with data to abak (at) abak win pl
I'll receive and tell You whether it populates ListView

 

by: sfernPosted on 2004-04-01 at 06:40:30ID: 10732409

I've sent you and email.

 

by: sfernPosted on 2004-04-01 at 06:51:12ID: 10732471

Did you get my email?

 

by: mocartsPosted on 2004-04-01 at 06:58:19ID: 10732545

hi, again
I have placed new version with some minor changes at http://www.grava.lv/files/pro/PopParse2.zip

about retrieving only two messages - did you removed test on Subject in code?

wbr, mo.

 

by: sfernPosted on 2004-04-01 at 07:03:06ID: 10732584

No i didn't....I'll check it out...thanks :)

 

by: mokulePosted on 2004-04-01 at 07:09:08ID: 10732628

to sfern
I don't no Your post was for me, but I didn't receive anything.
Changed spaces with dots? and at with @?

 

by: sfernPosted on 2004-04-01 at 07:32:07ID: 10732802

Great It's working fine :)

Thanks much for you help !!!

SFern

 

by: mocartsPosted on 2004-04-01 at 08:00:27ID: 10733029

you are welcome :)
wbr, mo.

20120131-EE-VQP-002

3 Ways to Join

30-Day Free Trial

The Experts

98% positive feedback on 31,087 answers since March 2000. angeliii is a Microsoft Most Valuable Professional for his work with MS SQL Server & Develoment.

He has also proven his knowledge of Visual Basic Programming, PHP Scripting and Oracle Databases.

The Experts

97% positive feedback on 10,752 answers since July 2000. lrmoore has more than 18 years experience in the networking industry.

The six-time Mircosoft MVPs specialties include firewalls, virtual private networking, and network management.

Testimonials

"...and excellent source for support... Kind of like having your very own IT dept." Electriciansnet

Testimonials

"I was apprehensive at signing up at first. However... it has already made my life as an IT administrator much easier." JaCrews

Testimonials

"WOW! You guys have great, active, and knowledgeable people on here." moore50

Business Clients

Business Clients

In the Press

"If you’ve got a question... Experts Exchange can supply an answer.”

In the Press

"...an invaluable aid for both IT professionals and those who require tech support."

In the Press

"where IT professionals provide quick answers on just about any topic"

Business Account Plans

Loading Advertisement...