Scalabium Software |
|
Knowledge for your independence'. | |
Home Delphi and C++Builder tips |
#145: Contact list in MS Outlook |
|
As you know I like MS Outlook because there a lot of possibilities and OLE automation of Outlook allow to solve possible any task. Today I want continue a serie of tips for MS Outlook. So how to read a collection of Contacts which are exist in MS Outlook? This task is very popular. For example, you want to develop a sample tool which will notify you about birthday for someone or you want to send messages to "mailing list". So you want to naviagte thru list of defined contacts and process any item. Below you'll find a sample code: const olFolderContacts = $0000000A; var outlook, NameSpace, Contacts, Contact: OleVariant; i: Integer; begin outlook := CreateOleObject('Outlook.Application'); NameSpace := outlook.GetNameSpace('MAPI'); Contacts := NameSpace.GetDefaultFolder(olFolderContacts); for i := 1 to Contacts.Items.Count do begin Contact := Contacts.Items.Item(i); {now you can read any property of contact. For example, full name and email address} ShowMessage(Contact.FullName + ' <' + Contact.Email1Address + '>'); end; Outlook := UnAssigned; end; if you need a birthday, you can retrieve it as DateToStr(Contact.Birthday) Any contact item have a lot of properties. See a list (alphabet): Birthday
|
Copyright© 1998-2024, Scalabium
Software. All rights reserved. |