Visit our Sponsor   Visit our Sponsor
delphi3000.com - the free delphi knowledge platform
delphi3000.com - the free delphi knowledge platform
491 Users Online NOW
Have a look at your member-status

connecting people's knowledge


  - Recent ArticlesRSS feed for Recent Articles on delphi3000.com
  - List of All Articles
  - Top Viewed Articles
  - Articles (+Attachem.)
  - Articles Of Interest
  - Categories
  - Top Uploader
  - Search
  - Index

  - My Home
  - Submit an Article
  - My Articles
  - My Personal Data
  - My Bookmarks
  - Activities
  - Login/Logout

  - Sign Up
  - Why Sign Up
  - Newsletter

  - Press
  - Advertise

  - Contact
  - Feedback





Community
Borland
ClubeDelphi
Dr. Bob
UK-BUG
Delphi Meetings
Planeta Delphi







Startblatt.de






Share this article with friendsShare this article with friends
Rate this articleRate this article - to keep the quality of delphi3000.com !
Comment this article or read through previous comments (4)


How to retrieve real email addresses from Outlook From Inbox mailsFormat this article printer-friendly!Bookmark function is only available for registered users!
Product:
Delphi 5.x (or higher)
Category:
OLE
Skill Level:
Scoring:
Last Update:
07/24/2002
Search Keys:
delphi delphi3000 article borland vcl code-snippet OUTLOOK INBOX EMAIL ADDRESS
Times Scored:
2
Visits:
10675
Uploader: Alain Godinas-Andrien
Company: Megabyte sa-nv
Reference: http://www.megabyte.be
 
Question/Problem/Abstract:
How to retrieve real email addresses from Outlook From Inbox mails
Answer:



I'd like to thank my friend Gilles Urbain who helped me to get it !
You can find him at gilles.urbain@automotive.be.tnsofres.com


unit UMain;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  ComObj, Outlook_TLB, StdCtrls;

type
  TForm1 = class(TForm)
    Button1: TButton;
    ListBox3: TListBox;
    Label1: TLabel;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }

  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.Button1Click(Sender: TObject);
var
    MyOutlook : _Application;
    MyNameSpace : _NameSpace;
    MyFolder : MAPIFolder;
    MyMail, MyReply : _MailItem;
    MailRecipients, ReplyRecipients : Recipients; // !! Collection !!
    ARecipient : Recipient; // !! Item !!
    i, j : Integer;
    seMailAddress : String;
begin
  MyOutlook := CoOutlookApplication.Create;
  Try
    MyNameSpace := MyOutlook.GetNamespace('MAPI');
    MyFolder := MyNameSpace.GetDefaultFolder(olFolderInbox);
    For i := 1 to MyFolder.Items.Count do
    Begin
      MyMail := (MyFolder.Items.Item(i) As _MailItem);
      // Comme nous voulons récupérer l'adresse email réelle de l'expéditeur.
      // As we want retrieve the real Sender email address.
      MyReply := MyMail.Reply;

      MailRecipients := MyMail.Recipients;
      ReplyRecipients := MyReply.Recipients;
      ListBox3.Items.BeginUpdate;
      // Récupération de toutes les adresses email réelles des personnes
      // en copie.
      // Retrieve ALL CC real email addresses.
      for j := 1 to MailRecipients.Count do
      Begin
        ARecipient := MailRecipients.Item(j);
        seMailAddress := ARecipient.Address;
        If Pos('@',seMailAddress) > 0 Then
          ListBox3.Items.Append(seMailAddress);
      End;
      // Récupération de l'adresse email réelle de l'expéditeur.
      // Retrieve the real Sender email address.
      for j := 1 to ReplyRecipients.Count do
      Begin
        ARecipient := ReplyRecipients.Item(j);
        seMailAddress := ARecipient.Address;
        If Pos('@',seMailAddress) > 0 Then
          ListBox3.Items.Append(seMailAddress);
      End;
      ListBox3.Items.EndUpdate;
    End;
  Finally
    MyOutlook.Quit;
  End;
end;

end.





Please rate this article!
Skill level:
BeginnerExpert

Useful:
No!Very!

Overall rating:
PoorExcellent



Comments to this article
Write a new comment
I want to get all emails from Outlook Address Book
    Eugene Shepelev (May 26 2003 2:01PM)

Some Emails with type 'EX' (Exchange) looks like
/o=M$/ou=Office/cn=Recipients/cn=Some/cn=Pupkin,
but I want to see Pupkin@Some.com.
How can I do it?

PS Please, send copy to my Email.

Respond

How to retrieve e-mail addresses from address book?
    Tadas Giniotis (Jun 20 2002 2:44PM)

I want to retrieve all e-mail addresses from the address book of MS outlook and to store them in a lets say edit1.text. But they have to be stored like this email@email.com; email2@email.com; email3@email.com and etc. I can`t figure out how to make such a procedure.
I dont need the names just the addresses.
Respond

RE: How to retrieve e-mail addresses from address book?
Bart D (Aug 25 2002 2:24PM)

add them to a dataset (recordset in ado) and sort them...this will do the job..
Respond

RE: RE: How to retrieve e-mail addresses from address book?
sridhara (Jul 13 2004 6:45AM)

Hi
Use this code this will give u all the addresses in the Outlook Persoal Address Book folder.

try
      Outlook := CreateOleObject('outlook.application');
      Outlook := Outlook.GetNameSpace('MAPI');
       for i := 1 to Outlook.AddressLists.Count do
          for j := 1 to Outlook.AddressLists(i).AddressEntries.Count do
            begin
              If Trim(Outlook.AddressLists(i).AddressEntries(j).Address) <> '' then
                CheckListBox1.Items.Add(Outlook.AddressLists(i).AddressEntries(j).Address);
            end;
        // Outlook.AddressLists(i).AddressEntries(j).Name +'    ' +
    except
      Outlook:=Unassigned;
    end;


in this replace the checkliost box with Edittext good Luck :)
Respond














 
Sign up to consume product discounts for Bronze memberships !

read more


  Visit our Sponsor

 

  Community Ad of
S. Kucherov
 
   














 







     
  Copyright © 2000 - 2007 delphi3000.com - All rights reserved. Terms of use. || Privacy
delphi3000.com is a service by bluestep.com IT-Services GmbH (Vienna)