Laci030999
asked on
Using Outlook components
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
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
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
listening
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('Outloo k.Applicat ion');
lblnCreated := False;
except
lobjOutLook := CreateOleObject('Outlook.A pplication ');
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;
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(
var
lobjOutLook, lobjMailItem: Variant ;
lblnCreated : Boolean;
begin
try
try
lobjOutLook := GetActiveOleObject('Outloo
lblnCreated := False;
except
lobjOutLook := CreateOleObject('Outlook.A
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;
Laci, some feedback would be appreciated... thanks!
ASKER
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
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
ASKER
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
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
Laci, good to know that you're back. Hope you had a good trip. We are looking forward to your comments.
ASKER
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
Thanx for Your Help!
Laci
Thanks for coming back! Have a nice day.
uses
ComObj;
var
Outlook, NameSpace, AddressList, AddressEntries: OLEVariant;
i: Integer;
begin
Outlook := CreateOleObject('Outlook.A
NameSpace := Outlook.GetNameSpace('MAPI
AddressList := NameSpace.AddressLists('Pe
AddressEntries := AddressList.AddressEntries
for i := 0 to AddressEntries.Count - 1 do
Memo1.Lines.Add(AddressEnt
end;
For an object reference, look in the Outlook help file under VB (the COM objects are language-independent).