Solved

Using Outlook  components

Posted on 2002-05-16
10
175 Views
Last Modified: 2010-04-04
Hi,

I would like to do a couple of tasks in Outlook which are very simple when I use the program myself, but I would like to do them from a Delphi app:

starting / closing Outlook

managing mails
  getting the content of the mail folders,
  getting a list of new mails,
  opening an e-mail,
  cheking for attachment,
  getting the content of attachment files,
  changing a mail's state,
  sending an e-mail with attachment,
 
managing the addressbook
  reading / changnig
  adding a new contact

Any help is appreciated, (it is kind of urgent, examples are some of the most useful ways of help :)))

Regards, Laci
 


0
Comment
Question by:Laci030999
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
10 Comments
 
LVL 14

Expert Comment

by:AvonWyss
ID: 7014109
You will need to use the Outlook COM object fot that. For instance, retrieving the address book would be like this:

uses
  ComObj;

var
  Outlook, NameSpace, AddressList, AddressEntries: OLEVariant;
  i: Integer;
begin
  Outlook := CreateOleObject('Outlook.Application');
  NameSpace := Outlook.GetNameSpace('MAPI');
  AddressList := NameSpace.AddressLists('Personal Address Book');
  AddressEntries := AddressList.AddressEntries;
  for i := 0 to AddressEntries.Count - 1 do
    Memo1.Lines.Add(AddressEntries.Item(i).name + ' (' + AddressEntries.Item(i).Address + ')');
end;

For an object reference, look in the Outlook help file under VB (the COM objects are language-independent).
0
 
LVL 14

Accepted Solution

by:
AvonWyss earned 300 total points
ID: 7014122
Just found the following link, which has extensive information on exactly this topic:
http://www.djpate.freeserve.co.uk/AutoOutl.htm
0
 
LVL 9

Expert Comment

by:ginsonic
ID: 7015539
listening
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 1

Expert Comment

by:rskathait
ID: 7016681
Hi,
Here is the code I am using. In this code you have access to Outlook Object and one MailItem Object. In the same manner you can manupulate any object inside Outlook.

You can see the outlook object model at:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/modcore/html/deovrunderstandingvbainoutlook.asp

I took help from this thread:
http://groups.google.com/groups?q=Delphi+Outlook+Object&hl=en&lr=&ie=UTF8&oe=UTF8&selm=7g7hpg%24lvc12%40forums.borland.com&rnum=2

http://www.dimastr.com/ gives lot of information to maupulate Outlook. Especially http://www.dimastr.com/babelfish/ is cool.


Regards,
rsk

uses
  ShellAPI, ComObj ;

procedure TForm2.edtOutlookDblClick(Sender: TObject);
var
  lobjOutLook, lobjMailItem: Variant ;
  lblnCreated : Boolean;
begin
  try
    try
      lobjOutLook := GetActiveOleObject('Outlook.Application');
      lblnCreated := False;
    except
      lobjOutLook := CreateOleObject('Outlook.Application');
      lblnCreated := True;
    end;
  except
    Exit;
  end;

  try
    try
      lobjMailItem := lobjOutlook.CreateItem(0);
      lobjMailItem.To := edtOutlook.Text;
      lobjMailItem.Display(True);
    except
      Exit;
    end;
  finally
    lobjMailItem := Unassigned;
    if lblnCreated = True then
      lobjOutlook.Quit;;
    lobjOutLook := Unassigned;
  end;
end;

0
 
LVL 14

Expert Comment

by:AvonWyss
ID: 7017020
Laci, some feedback would be appreciated... thanks!
0
 

Author Comment

by:Laci030999
ID: 7029625
Hi Experts,

I had go for an unexpected trip, din't even have the time to 'say goodbye' ... I appologize. Now I'm catching up with my work & evaluating the info you provided.

Appreciate your help, I'll be back when I'm through.

Best regards, Laci
0
 

Author Comment

by:Laci030999
ID: 7029648
Hi Experts,

I had go for an unexpected trip, din't even have the time to 'say goodbye' ... I appologize. Now I'm catching up with my work & evaluating the info you provided.

Appreciate your help, I'll be back when I'm through.

Best regards, Laci
0
 
LVL 14

Expert Comment

by:AvonWyss
ID: 7029887
Laci, good to know that you're back. Hope you had a good trip. We are looking forward to your comments.
0
 

Author Comment

by:Laci030999
ID: 7845119
Oooops! Experts, I'm sorry! I have forgotten to close this Q. The Information I needed was provided by AvonWyss.

Thanx for Your Help!

Laci
0
 
LVL 14

Expert Comment

by:AvonWyss
ID: 7849585
Thanks for coming back! Have a nice day.
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
Suggested Courses
Course of the Month3 days, 11 hours left to enroll

630 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question