Vous êtes sur la page 1sur 7

Delphi Programming: Outlook MAPI Fields

http://www.experts-exchange.com/Programming/Programming_Languag...

Site News | ExpertCare | Support | Help

My Account
December 16, 2006 - 06:26AM PST

Premium Services

Buy Points

Logout

Home

Storage

OS

DB

Security

Programming

Web Dev

Hardware

Networking

Apps

Misc

Home All Topics Programming Languages Delphi Viewing a Question Search 1,774,640 Solutions Search Help Advanced Search

Title: Outlook MAPI Fields


asked by thornton_paul on 05/28/2001 05:22AM PDT This solution was worth 100 Points and received a

grade of A

Hi All, I'm writing an application which retrieves data from Outlook using MAPI. Everything works fine as long as I know which fields I want to display. I would however like to write a generic display grid which displays all the fields for all the items in a folder (without knowing before hand which fields are going to be there). My question is, is there a way to retrieve all the fields for an outlook item and then retrieve the data for those fields? Currently, I'm doing it something like this (some stuffs been removed to make it clearer): procedure TForm1.AddItems(Node : TTreeNTNode; ListView : TListView); var i : Integer; begin if (not assigned(node)) or (Node = LastNode) then Exit;
Page Options

Reload This Question Delphi Area Send To A Friend

ListView.Items.BeginUpdate; ListView.Items.Clear; try if (assigned(node)) and (assigned(node.data)) then begin

Programming Channels

Game Dev. (5) Platforms (8) Languages (20) .NET (3) C#

1 of 7

12/16/2006 9:44 AM

Delphi Programming: Outlook MAPI Fields

http://www.experts-exchange.com/Programming/Programming_Languag...

Ask a Question
Who's using EE?

You're in good company


Page Editor

for I := 1 to PNodeData(Node.Data).Folder.Items.Count do begin try With ListView.Items.Add do try Caption := PNodeData(Node.Data).Folder.Items(i).FullName; SubItems.Add(PNodeData(Node.Data).Folder .Items(i).MobileTelephoneNumber); except Delete; Break; end; except Break; end; end; end; finally ListView.Items.EndUpdate; LastNode := Node; ProgressBar1.Visible := FALSE; end; end; I would like to do something like: Caption := PNodeData(Node.Data).Folder.Items(i).Fields(0) Hope this makes sense. Cheers, Paul
Send to a Friend Printer Friendly See Solution

Delphi kretzschmar
Featured Expert

ciuly Ask An Expert Now!

C++ (2) C Delphi Java (1) JavaScript MFC OWL Pascal Perl PowerBuilder Visual Basic (2) Assembly Eiffel Python C++ Builder ASP.NET VB.NET Visual C++.NET Wireless (13) Web Languages (10) Software Design All Topics
Logged In As gspears

My Open Questions (1) Logout

Top 15 Overall

Delphi Programming

kretzschmar rllibby Madshi Slick812 geobul mnasman inthe ciuly EddieShipman Ferruccio68 Workshop_Alex DragonSlayer Epsylon esoftbg Lee_Nover

1314176 1084806 661400 645363 625749 548110 514714 514233 458590 439154 437128 394371 324729 316932 297111

Hall of Fame
Top 15 Yearly Delphi Programming

ciuly rllibby

443523 371049

2 of 7

12/16/2006 9:44 AM

Delphi Programming: Outlook MAPI Fields

http://www.experts-exchange.com/Programming/Programming_Languag...

Go Pro with Premium Services


More Answers Get instant IT solutions that solve your toughest IT problems, provide instant answers, and save thousands of jobs. Power Search 5 times faster Search our entire We have the answers you want knowledge base for instant Access more IT solutions solutions. Access more IT experts Fast, organized, and powerful. Find multiple solutions to your specific question. Largest Solution Knowledge Base Worlds largest IT solutions knowledge base. Find multiple solutions to your specific question. Personal Knowledge Base Develop your own personal library of IT solutions. No More Ads Enough said. Customized Navigation Quick links provide one click navigation to the technology channel of your choice. Premium Services Instant Help Instant personal help from an EE concierge.

TheRealLoki TName EddieShipman mikelittlewood kretzschmar atul_parmar kfoster11 calinutz mokule Slick812 Workshop_Alex sun4sunday PierreC Hall of Fame

163067 130452 122563 114164 105899 91383 87479 85113 83236 81796 74597 71672 69400

Ask your Delphi Programming Question

it's quick and easy


What is your expert ranking? Topic Area Certified Expert Your Level

Get Certified Now Master 50,000 Guru 150,000 Wizard 300,000 Sage 500,000 Genius 1,000,000

Comment from jeurk Date: 05/28/2001 10:51AM PDT

Comment

Hi, I'm not sure that you explain your problem correctly. Don't take offense... Is what you need the fact that you want to

3 of 7

12/16/2006 9:44 AM

Delphi Programming: Outlook MAPI Fields

http://www.experts-exchange.com/Programming/Programming_Languag...

know how to test for the type of a given Item, like a mail or a contact or a schedule ? Because you must understand that such a thing you are searching does not logically exist because you want to display different items in the same grid. It's like if you had a TTable that is holding rows of different natures. So here is my help to you. check an item for it's type (to show you the idea): var mi: MailItem; ai: AppointmentItem; item: IUnknown; begin item := folder.items (i); if item.QueryInterface (MailItem, mi) = S_OK then begin ShowMessage ('Is MailItem'); mi.Foo; end else if item.QueryInterface (AppointmentItem, ai) = S_OK then begin ShowMessage ('Is AppointmentItem'); ai.Foo; end; ...etc end; -connect to outlook like if it were a dataset: http://homepages.borland.com/torry/vcl/ system/appscommunications/outltb.zip By Lothar Perr. Component to connect Delphi Applications to MS-Outlook 97 and 2000 (including the Mails, Contact list, Notes, Apointments, Command bars Items..). Sample Included. Fully functional Source: Included Exe-demo included I think this should help you. Let me know if you need more. John Comment from thornton_paul Date: 05/29/2001 05:38AM PDT

Author Comment

4 of 7

12/16/2006 9:44 AM

Delphi Programming: Outlook MAPI Fields

http://www.experts-exchange.com/Programming/Programming_Languag...

What I was actually asking for was something like the TTable.Fields property. It seems that there are a set selection of fields for each item. i.e. a Contact item will always have FirstName, LastName, MobileTelephoneNumber etc. I wanted to programatically find out what these fields were, then add them as columns to a listview. Is there any reason why this shouldn't be possible. The fields for a particular item appear to remain constant. Cheers, Paul Comment from thornton_paul Date: 05/29/2001 07:07AM PDT

Author Comment

One of the things I've noticed when reading the Folders and Items is that it is very, very slow. Is this something I might be doing wrong or is it normal? Accepted Answer from jeurk Date: 05/29/2001 10:24AM PDT Grade: A

Accepted Answer

About the fields, it's simply not possible... Your only choice is to do it by hand. If this was possible it would be much easier to work with outlook... Anyway, this is not a big issue, your code is just bigger... Here is another example of a TOutlookDataset that lets you browse the mail only... http://chlichti.home.mindspring.com/html/ outlookds.html

About the speed issue: Optimizing your code (by deborah pate) Automation is slow. To speed things up, you need to reduce the amount of toing-and-froing between the automation client and server. First and foremost, use early binding rather than late binding. When you use variants, every function call results in calls to IDispatch GetIDsOfNames and IDispatch.Invoke - a big waste of time when you can call the function directly with early binding.

5 of 7

12/16/2006 9:44 AM

Delphi Programming: Outlook MAPI Fields

http://www.experts-exchange.com/Programming/Programming_Languag...

Secondly, try to work with the automation server's macro language to reduce client-to-server traffic. Visual Basic for Applications may not be lightning fast, but it's likely to be faster than sending information from the server to the client and back again. Thirdly, use local variables and with clauses wherever possible, to reduce the number of calls to the server. In other words, don't do this: (Excel.ActiveSheet as _Worksheet).Cells.Item[1,1].Name := 'FirstCell'; (Excel.ActiveSheet as _Worksheet).Cells.Item[1,1].Value := 'This is the first cell'; Instead, do this: with (Excel.ActiveSheet as _Worksheet).Cells.Item[1,1] do begin Name := 'FirstCell'; Value := 'This is the first cell'; end or this:

var R: Range; ... R := (Excel.ActiveSheet as _Worksheet).Cells.Item[1,1]; R.Name := 'FirstCell'; R.Value := 'This is the first cell'; Fourthly, make sure you use any of the application's own methods for speeding things up. For example, Microsoft Office applications have a ScreenUpdating property which you can use to stop screen updates temporarily while your code executes, which can make a big difference to the speed.

John. Comment from thornton_paul Date: 05/30/2001 06:37AM PDT

Author Comment

Thanks for your help, your info has been bery useful.

6 of 7

12/16/2006 9:44 AM

Delphi Programming: Outlook MAPI Fields

http://www.experts-exchange.com/Programming/Programming_Languag...

Cheers, Paul Comment from jeurk Date: 05/30/2001 08:11AM PDT

Comment

I'm happy if I could help. Thanks for the points. If you have other questions don't hesitate :) Will the result of your programming be available when it gets finished ? Because I'm interessed :) Best regards... John. Comment from thornton_paul Date: 05/31/2001 12:12AM PDT

Author Comment

You can have a copy now if you like... My company is tendering for a project which will sychronise between Outlook and a new palm type device. I've been doing a bit of a pre-study to make sure that it's possible. If you give me your email address, I'll send you the project. Cheers, Paul

Email Notification: Subscribe Home All Topics Programming Languages Delphi Q_20125519.html

Get your IT Solutions GUARANTEED!


More IT professionals have found their answers instantly at Experts Exchange than at any other IT site
Get Instant Answers

or ask your specific question to one of our 218K IT experts

ASK AN EXPERT NOW


Contact Us | Member Agreement | Internet Rank | Privacy Policy | Supporters | Site Map Copyright Experts Exchange LLC 2006. All rights reserved.

7 of 7

12/16/2006 9:44 AM

Vous aimerez peut-être aussi