Article View: borland.public.cppbuilder.nativeapi
Article #10218Re: Outlook
From: Colin B Maharaj
Date: Wed, 05 May 2004 21:29
Date: Wed, 05 May 2004 21:29
48 lines
2361 bytes
2361 bytes
If you have BCB6.0
1. Drop a TOutlookApplication component on a form.
2. Place a Button and a String Grid
3. Try this in the Button handler.
NameSpacePtr pNameSpace ;
FoldersPtr pFolders ;
MAPIFolderPtr pFolder ;
ItemsPtr pItems ;
ContactItemPtr pContact;
OutlookApplication1->Connect();
pNameSpace = OutlookApplication1->GetNamespace (WideString("MAPI"));
pFolders = pNameSpace->Folders;
pFolder =
pNameSpace->GetDefaultFolder(Outlook_2k::OlDefaultFolders(olFolderContacts));
pItems = pFolder->Items;
int NumberOfContacts = pFolder->Items->Count ;
StringGrid1->Cells[0][0] = "Name";
StringGrid1->Cells[1][0] = "Email";
StringGrid1->RowCount = NumberOfContacts + 1;
for (int i=0; i<NumberOfContacts; i++)
{
if (i==0) pContact = pFolder->Items->GetFirst() ;
else pContact = pFolder->Items->GetNext() ;
StringGrid1->Cells[0][i+1] = pContact->FullName;
StringGrid1->Cells[1][i+1] = pContact->Email1Address;
}
OutlookApplication1->Disconnect();
4. The stuff like Email1Address an so on can be go by opening outlook,
and running the Visual Basic Editor, then looking at the object
inspector (and online help).
Ellis wrote:
> hi everybody :)
>
> i want to read and write to Outlook's address book from my application,
> how can i do this ?
>
> Ellis
>
>
Technical Details
Message-ID:
<40995d72$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!controlnews3.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<4099407c$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10cc67,2a3b2df0edf4f9e2 X-Google-Attributes: gid10cc67,public Date: Wed, 05 May 2004 17:29:30 -0400 From: Colin B Maharaj <noreply@myhost.com> User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7a) Gecko/20040219 X-Accept-Language: en-us, en MIME-Version: 1.0 Newsgroups: borland.public.cppbuilder.nativeapi Subject: Re: Outlook References: <4099407c$1@newsgroups.borland.com> In-Reply-To: <4099407c$1@newsgroups.borland.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit NNTP-Posting-Host: 200.108.15.96 Message-ID: <40995d72$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1083792754 200.108.15.96 (5 May 2004 14:32:34 -0700) Lines: 48 Path: arc1-ca.pugleaf.net!controlnews3.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail